Getting data from your test cases repository can be useful to have it handy in any other application where you may need test case details, such as an IDE, a data analysis tool, or even a CLI that can perform any kind of operations with this data.
By fetching test cases details, you should be able to generate artifacts based on your test case design and get customized insights using external tools, such as:
- Analyze test case design in external tools
- Generate automated tests from existing test cases
Real examples | Use case |
---|---|
Jetbrains IDEs | Test management plugin with the ability to auto-generate automated test skeletons |
Getting test cases
To analyze your test case design and manage your test cases outside TestRail, for instance, using a test automation tool, you will want to fetch the information from your test cases.
GET index.php?/api/v2/get_cases/{project_id}
curl -X GET \
-u "user@example.com:password" \
"https://example.testrail.io/index.php?/api/v2/get_cases/3"
None
{
"offset": 0,
"limit": 250,
"size": 3,
"_links": {
"next": null,
"prev": null
},
"cases": [
{
"id": 4075,
"title": "Successfully login (Steps)",
"section_id": 497,
"template_id": 2,
"type_id": 11,
"priority_id": 3,
"milestone_id": null,
"refs": null,
"created_by": 5,
"created_on": 1684927352,
"updated_by": 5,
"updated_on": 1684929173,
"estimate": "1m",
"estimate_forecast": null,
"suite_id": 53,
"display_order": 1,
"is_deleted": 0,
"case_assignedto_id": null,
"custom_automation_type": 0,
"custom_preconds": "Go to login page ",
"custom_steps": null,
"custom_testrail_bdd_scenario": null,
"custom_expected": null,
"custom_steps_separated": [
{
"content": "Input valid email and password",
"expected": "Fields should be highlighted in green",
"additional_info": "",
"refs": ""
},
{
"content": "Click submit",
"expected": "User should be logged in and redirected to the homepage",
"additional_info": "",
"refs": ""
}
],
"custom_mission": null,
"custom_goals": null,
"comments": []
},
{
"id": 4077,
"title": "Successfully register new user (Text)",
"section_id": 497,
"template_id": 1,
"type_id": 11,
"priority_id": 3,
"milestone_id": null,
"refs": null,
"created_by": 5,
"created_on": 1684929198,
"updated_by": 5,
"updated_on": 1684929282,
"estimate": "2m 30s",
"estimate_forecast": null,
"suite_id": 53,
"display_order": 2,
"is_deleted": 0,
"case_assignedto_id": null,
"custom_automation_type": 0,
"custom_preconds": "Go to the register page",
"custom_steps": "Input valid information in all fields\r\nClick register",
"custom_testrail_bdd_scenario": null,
"custom_expected": "User should be registered and prompted to confirm his email address ",
"custom_steps_separated": null,
"custom_mission": null,
"custom_goals": null,
"comments": []
}
]
}
Filtering test cases with query parameters
- Get all the test cases that are in project 34 (project ID of 34), suite with ID of 2 and priority 3 or 4
GET index.php?/api/v2/get_cases/34&suite_id=2&priority_id=3,4 - Get 10 test cases from project 34
GET index.php?/api/v2/get_cases/34&limit=10 - Only returning test cases from project 34 starting the offset number
GET index.php?/api/v2/get_cases/34&offset=5 - Filter cases in project 34 with a filter string of "login"
GET index.php?/api/v2/get_cases/34&filter=login - Combined usage
GET index.php?/api/v2/get_cases/34&offset=5&limit=10&filter=login