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

Issue with automating multi-config test plan creation

I am trying to automate the creation of a test plan with a single entry for multiple runs of different config_id sets, but end up getting only single run created with my config_ids ignored:

Testrail version: 6.0.0.4140

POST

url: my_testrail_server /index.php?/api/v2/add_plan/5
data: {
‘name’: ‘0.0_ATestNightly’,
‘description’: ‘Nightly ATest runs’,
‘milestone_id’: 2,
‘config_ids’: [2, 5, 20],
‘entries’: [
{‘runs’: [
{‘config_ids’: [5, 20],
‘name’: ‘0.0_ATestNightly20_5’},
{‘config_ids’: [2, 20],
‘name’: ‘0.0_ATestNightly20_2’}]
,‘suite_id’: 29}]
}

POST RESULT

{‘assignedto_id’: None,
‘blocked_count’: 0,
‘completed_on’: None,
‘created_by’: 7,
‘created_on’: 1568891810,
‘custom_status1_count’: 0,
‘custom_status2_count’: 0,
‘custom_status3_count’: 0,
‘custom_status4_count’: 0,
‘custom_status5_count’: 0,
‘custom_status6_count’: 0,
‘custom_status7_count’: 0,
‘description’: ‘Nightly ATest runs’,
‘entries’: [{‘id’: ‘8786b2dc-bda7-4785-a24c-5d624ef65843’,
‘name’: ‘MaxCore’,
‘runs’: [{‘assignedto_id’: None,
‘blocked_count’: 0,
‘completed_on’: None,
‘config’: None,
‘config_ids’: ,
‘created_by’: 7,
‘created_on’: 1568891810,
‘custom_status1_count’: 0,
‘custom_status2_count’: 0,
‘custom_status3_count’: 0,
‘custom_status4_count’: 0,
‘custom_status5_count’: 0,
‘custom_status6_count’: 0,
‘custom_status7_count’: 0,
‘description’: None,
‘entry_id’: ‘8786b2dc-bda7-4785-a24c-5d624ef65843’,
‘entry_index’: 1,
‘failed_count’: 0,
‘id’: 125,
‘include_all’: True,
‘is_completed’: False,
‘milestone_id’: 2,
‘name’: ‘MaxCore’,
‘passed_count’: 0,
‘plan_id’: 122,
‘project_id’: 5,
‘retest_count’: 0,
‘suite_id’: 29,
‘untested_count’: 9,
‘url’: ‘ my_testrail_server /index.php?/runs/view/125’}],
‘suite_id’: 29}],
‘failed_count’: 0,
‘id’: 122,
‘is_completed’: False,
‘milestone_id’: 2,
‘name’: ‘0.0_ATestNightly’,
‘passed_count’: 0,
‘project_id’: 5,
‘retest_count’: 0,
‘untested_count’: 9,
‘url’: ‘ my_testrail_server /index.php?/plans/view/122’}

Have I got something wrong?

Hi @jibin,

The purpose of ‘add_plan’ is only to create the test plan, not test runs within it. The workflow would be to run ‘add_plan’ to first create the test plan, then ‘add_plan_entry’ to create/add test runs.

Your test run configuration would go under the ‘add_plan_entry’ portion of a creating a test plan via API.

Please reference the following documentation to ensure you are using the correct variables for the corresponding method.

http://docs.gurock.com/testrail-api2/reference-plans

Working solution for adding test runs as part of add_plan from @jon.reynolds


When using the config_ids field for creating a test plan with configurations, your request should be formatted as follows:
{
“name”: “System test”,
“entries”: [
{
“suite_id”: 1,
“include_all”: true,
“config_ids”: [1, 2, 4, 5, 6],
“runs”: [
{
“include_all”: false,
“case_ids”: [1, 2, 3],
“assignedto_id”: 1,
“config_ids”: [2, 5]
},
{
“include_all”: false,
“case_ids”: [1, 2, 3, 5, 8],
“assignedto_id”: 2,
“config_ids”: [2, 6]
}

]
},

]
}

Based on the example you provided, you are including the ‘config_ids’ field for the set of runs outside of the ‘entries’ field, instead of inside it.