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

Get all the results of a run with get_results_for _run



I’m trying to get all the results for a run through the get_results_for_run API but I can’t manage to get all the results of the run.

I have seen in the following topic that it can happen on big runs:

But I don’t see in the API documentation how I can manage to have everything in one call. Can someone help me?

TestRail Activity

This just came up with the JIRA gadgets (JIRA gadgets for TestRail). They way I handled it was I used the filter options limit and offset. (I also used the status_id and created_after to limit the results returned. Using status_id is a nice way to filter out the null statuses.) Here’s the high level algorithm I used:

offset = 0;
done = False;
while (done == False) {
  results_obj = send_get("index.php?/api/v2/get_results_for_run/1&limit=250&offset=" + offset);

  /* do some sort of loop or function to get the number of results returned */
  numReturned = getNumberOfRow(results_obj);

  if numReturned >= 250 {
    offset = offset + 250;
  } else {
    done = True;

So the code will keep making calls to get_results_for_run (with a different offset) if it returns the limit with the previous call. I used 250 because that’s the maximum allowed value by the API.


Thanks for sharing this, Don!

@vverdeil: if a test run has more than 250 results, you can use the limit and offset parameters to iterate through the list of results. This is to make sure that even runs with thousands or more of results can be handled well and this is a common concept with APIs. You can see the same approach also in TestRail’s UI when you view the milestone activity/results, for example (with the pagination features).



Thanks @donalaya for the help and the example of code it really helped me.