Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.

Updating custom fields with statistic of number of times a test is run and PASS/FAIL ratio


We have a project where we run the same test multiple times in the same plan and record observations and status (PASS/FAIL) after each run. We would like to add and automatically update (I suppose via a UI script) one or more custom fields to the test that are updated after each test run. I need some pointers how to get started:
In the UI script, is there a way to extract the number of runs of a particular test and to get the result of each test? It is possible to update the custom fields after having extracted this information.


Hello Petter,

Thanks for your posting! Can you share a few more details on what you are trying to accomplish? For example, do you plan to update case fields or custom fields of test results?



Hello Tobias,

for a run of a test (where the ID starts with R) we would like to add two columns, noOfRuns and passFailRatio. Every time we add a new result to the run of this test we want to update these two columns accordingly. The passFailRatio will be calculated from the value set in the mandatory Status field in the Add Result window and noOfRuns will show the number of runs (equal to the number of results added) of the test.



I guess this the following feature request would take of most of the problem:

Do you have any plans to release a feature like this?
Or is it possible to create a UI script for it?


Hello Petter,

Thanks for your additional feedback. There are no immediate plans for this feature currently but it’s on our longer term list of features to look into. There are some really cool applications for this features but it’s also a very complex one and there are lots of features more customers would benefit from first so it doesn’t have the highest priority at the moment to be honest. It’s not really possible to emulate this via UI script as this would require changes on TestRail’s side as well.

Regarding the noOfRuns and passFailRatio: TestRail would already show this on the History & Context tab per test and this should be exactly what you are you looking for. This also includes tests of other test runs but the current test is highlighted. If the test contains multiple results TestRail shows a little stats bar with the history statuses (your passFailRatio):

(You can hover over each stats bar to see the details)

I hope this helps!