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

Fetch defects associated with testcase id in a run - using pytest_testrail


I am a new user of pytest_testrail ( python API for testrail ). Could someone help to show an approach to get all the bugs associated with test case in test run. For instance below is the scenario

In test run id # 101 there is a test case ( testcase id: 12 ) . There is a bug number # bug-22 in “Defects All” field of test case in test run.

How we can get/fetch the bug mentioned in the test case ( in test run ) using pytest_testrail Python API ? Thank you very much


Hi @anan,

Thanks for your posting! Defect details can be read via the API for a run with the get_results_for_run API method:

The ‘defects’ field of the results would contain the issue/bug IDs that were added to the test run.