How to create test result via reportable REST Api /oslc api in ETM
Hello,
I am currently working on automating the complete RQM/ETM Test case execution model using reportable rest api /oslc api but till date i was just using GET command and things were bit easy to understand :) but now i am finding some trouble while using PUT command , i read somewhere in blog that we use PUT command for test artifacts and POST for attachment (please correct me)
Now coming to part What i need? :
My input :
-> TCER ID
-> Test Case ID
-> Test Plan ID
-> Test Verdict(passed, failed ,...)
-> Start time
-> End time
-> Artifactory Link that could be linked in test result somewhere
Now i need the rest uri to create test result and link tcer,test case, test plan and update verdict and time , is it possible ?
I know how to update value using PUT command but how to create test result i am not sure, can anyone help me out
Thank you
Accepted answer
First do a GET on an existing test case result to get an example of the XML which is needed to create a new test case result.
Here is what I did, headers:
Accept: text/xml
Content-Type: application/xml
Next I copied the XML from the response into Notepad and removed the following:
<ns2:webId>11</ns2:webId>
<ns4:creator name="Brian" ns1:resource="https://base-win2012r2:9443/jts/resource/itemName/com.ibm.team.repository.Contributor/brian">brian</ns4:creator>
<ns2:creationDate>2021-09-14T17:23:47.942Z</ns2:creationDate>
<ns6:updated>2021-09-14T17:27:11.234Z</ns6:updated>
<ns16:starttime>2021-09-14T17:23:47.942Z</ns16:starttime>
<ns16:endtime>2021-09-14T17:27:11.203Z</ns16:endtime>
<ns16:totalRunTime>204000</ns16:totalRunTime>
<ns16:actualRunTime>203261</ns16:actualRunTime>
<ns2:alias type="string">urn:com.ibm.rqm:executionresult:11</ns2:alias>
I then used the remaining XML to PUT the result on the server.
Here is what I did, headers:
Accept: text/xml
Content-Type: application/xml
Note, the last part of the URI needs to be unique, e.g. 20220321_1150PM. This is the External ID. In the documentation provided by Ralph it defines the external ID as the following:
A unique ID provided by the user when creating a new resource with a PUT. Resources created in the Rational Quality Manager UI will not have external IDs. An external ID can contain any characters allowed in a URI (URI-reserved characters (see RFC 2396) except the '/' character MUST be URL encoded in GET/PUT requests) and should NEVER contain urn:com.ibm.rqm: <resource type>: (internal ID).
Comments
It is possible to use POST instead of PUT, in which case the ID gets created for you.
1 vote
@Ralph Schoon,
Which means if i use POST then i don't need to worry unique ID mentioned in Brian post, Excellent thanks!!
One other answer
Here is the documentation https://jazz.net/wiki/bin/view/Main/RqmApi#Usage_Basics hinting that you would do a POST to create items.
Comments
@Ralph Schoon,
Thanks for sharing this info link , i have done some tryouts not sure whether its optimal approach or not but some expert advice is surely required here :)
Thank you
Comments
Brian Lahaie
Mar 22 '22, 2:18 a.m.Its definitely possible to create a test case result using the REST APIs. I will add an answer below.
1 vote
Rajat Krishnan
Mar 22 '22, 2:46 a.m.