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

Fetch untested test results from a test run using APIs

#1

I’m trying to fetch all the “untested” tests from a test run, I don’t find any API which is fetching all the untested tests from a test run. Is there a way to fetch this information using testrail APIs?

How to find test case that have never been executed?
#2

there is! get the test run results api, then the ‘test’ status will have a number - that number tells you what status the test is in!

here is some code (python) i use to do exactly what you’re saying:

    def get_tests_in_run_by_status(self, runId, status):
        test_names = []
        request = str.format('get_tests/{}', runId)
        tests = self.client.send_get(request)
        for test in tests:
            if test['status_id'] == status:
                test_names.append(test['case_id'])

    return test_names

untested = status 3

#4

Hi @bschwen, thanks for the prompt response. I tried this approach as well, after I get the case_id, when I make a get_results_for_case API call with the run_id and case_id, it returns an empty list.
Seems like Untested (status_id == 3) tests are not being filtered internally and not included in the response to the client.

#5

Hi @vmware_velocloud,

You are correct that the ‘get_results’ methods will not include any tests which are untested (status_id: 3). Any tests which are ‘untested’ will not have any results added to them and therefore would not be included in the results requests.

Instead, you can use the ‘get_tests’ method with a ‘status_id=3’ filter applied to retrieve the untested tests in a run.

Hope this helps,
Jon

1 Like
#6

Thanks @jon.reynolds. Makes sense.

FYI - Few of our users posted test results without changing status_id and only adding an assignee to the test, which populated a test result for ‘Untested’ tests as well which caused a confusion for me. All is clarified now, thanks!

1 Like