How to add test case id to the test run?

Tuesday, December 19, 2023
Avatar

Hello,

I'm using the Request Body to POST test run record ("projects/{project_id}/test-runs/record").

But for some reason I see only TestStepId but now TestCaseId in the output.

However, if I do it manually then I can see both.

What am I missing in my Body Request?

start_time =    datetime.datetime.now().isoformat()
end_time =      datetime.datetime.now().isoformat()
body = {
    "StartDate":  start_time,
    "EndDate":    end_time,
    "TestCaseId":222222,
    "TesterId": 111,
    "ReleaseId":5555,
    "ExecutionStatusId":2,
    'RunnerName': 'Name Surename',
    'ProjectId': project_id,
    'ArtifactTypeId': 2,
    'RunnerTestName': 'Test Name!',
    "TestRunSteps": [
        {
        'Position': 1,
        "TestStepId": 333337,
        "TestCaseId":222222,
        'ProjectId': 112,
        "ExecutionStatusId": 2,
        "Description": "info goes here",
        "ActualResult": "result goes here",
        'ArtifactTypeId': 7,
        },
        {
        'Position': 2,
        "TestStepId": 333338,
        'ProjectId': 112,
        "TestCaseId":222222,
        "ExecutionStatusId": 2,
        "Description": "info goes here",
        "ActualResult": "result goes here",
        'ArtifactTypeId': 7,
        }
    ],
}
RUNNER_LINK = f"https://some_comapmy.com/SpiraTest/Services/v7_0/RestService.svc"
POST_TEST_RUN = f"projects/{project_id}/test-runs/record"
tr_record_url = f'{RUNNER_LINK}/{POST_TEST_RUN}'
request = requests.post(tr_record_url, data=json.dumps(body), params=params, headers=headers)
request.content

Best Regards,
N

3 Replies
Wednesday, December 20, 2023
Avatar
re: new_spiratest_user Tuesday, December 19, 2023

Typically that field is populated with the Test Case ID because for manual tests you can include test steps from other test cases, so it's useful to know if it was from the primary test case, or one of the linked child test cases.

For automated tests, the results and the steps are always related to the primary test case, so the API doesn't populate that value on the steps. You can just see the test case on the top of the page.

Wednesday, December 20, 2023
Avatar
re: inflectra.david Wednesday, December 20, 2023

Hi David,

Got it.  Thank you for the quick response! 

I wish you Merry Christmas and Happy New Year!

Thursday, December 21, 2023
Avatar
re: new_spiratest_user Wednesday, December 20, 2023

You're very welcome!

You too, happy holiday season.

Spira Helps You Deliver Quality Software, Faster and With Lower Risk

And if you have any questions, please email or call us at +1 (202) 558-6885

 

Statistics
  • Started: Tuesday, December 19, 2023
  • Last Reply: Thursday, December 21, 2023
  • Replies: 3
  • Views: 351