It's all about the answers!

Ask a question

How do I change the state of a test case using the (rest or oslc) API?


David Babuder (1539) | asked Apr 18 '16, 4:25 p.m.
We are using CLM 6.0 tools.
I started with the RQMUrlUtility, and am able to successfully create a test case and a test script.
In both cases I cannot import them in the desired state. They always want to be in the Draft state.
Because of the large number of test cases and test scripts, I want to modify the states via the program.

I can retrieve the test case's (or test script's) internal id. I can get the whole test case/script via the rest API using the internal id.
I cannot determine how to set the test case state (I also need to get the test case state to verify the tool did what I wanted).

Help!
Thanks

 

2 answers



permanent link
Donald Nong (14.5k614) | answered Apr 19 '16, 2:03 a.m.
It should be no different from updating other attributes. But as you observed, you cannot set the state to any value because it has to conforms to workflow. For example, by default, the "draft" state is the starting state. To see the current configuration of workflows, go to Manage This Project Area and choose Workflows at the bottom left. Note that each test artifact type can have different workflow.

For your issue, you can do it in two ways.
1. Create the test artifacts as usual, and move the state to the desired one according to the workflow - you may need to do multiple PUT operations against a test artifact to achieve this.
2. Only when you are the only one actively using the RQM project:
a. Change the starting state to the desired one in a workflow of a test artifact type.
b. Save the change.
c. Create test artifacts of that particular state and particular type.
d. Repeat a. - c. for each state.
e. Change the starting state back to Draft.
f. Repeat a. - e. for each test artifact type.

Comments
David Babuder commented Apr 19 '16, 9:40 a.m. | edited Apr 20 '16, 12:25 a.m.

I need to make the change programmatically (option 1 in the response from Donald Nong), as other people may be using the product at the same time that I am (so option 2 is not a good choice).

The response does not answer the question of how to update the state attribute. How can I do either of:

- use the API to request an action that would trigger the state transition from one state to another

- use the API to update the data so that the state transitions from one state to another


Donald Nong commented Apr 20 '16, 12:35 a.m. | edited Apr 20 '16, 12:36 a.m.

I thought it's quite straightforward so I didn't put in the details. Sorry about that. You do not invoke an action at all, and you just update the test artifact with the target state directly. For example, from the workflow, you know that you can move an artifact from Draft to Ready For Review, and the ID for the said state is "com.ibm.rqm.planning.common.new" and "com.ibm.rqm.planning.common.underreview" respectively (you can find it out by querying the existing artifacts of the said state). Then for the artifact you need to update, do a GET operation, and you should get something like this in the response.

<ns5:state ns7:resource="https://clm:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/process-info/_un7MMIPsEeSArJ5EtUYmDQ/workflowstate/com.ibm.rqm.process.testcase.workflow/com.ibm.rqm.planning.common.new">com.ibm.rqm.planning.common.new</ns5:state>
Next you will replace the above line with this.
<ns5:state ns7:resource="https://clm:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/process-info/_un7MMIPsEeSArJ5EtUYmDQ/workflowstate/com.ibm.rqm.process.testcase.workflow/com.ibm.rqm.planning.common.underreview">com.ibm.rqm.planning.common.underreview</ns5:state>
And finally you will make this modified response body as the payload of the PUT(modify) operation against the same artifact. If everything goes to plan, you should get an HTTP 200 response code and the test artifact gets updated with the new state.



David Babuder commented Apr 20 '16, 2:26 p.m. | edited Apr 20 '16, 2:29 p.m.

Thanks!  The API documentation lead me to believe that with a testcase and a /state somewhere in the URI, I could just update the state! (see "https://www.ibm.com/support/knowledgecenter/SSYMRC_6.0.1/com.ibm.rational.test.qm.doc/topics/qm/Test-Case.html?lang=en"  and the reference to "/content/qm:testcase/alm:state/@rdf:resource" lead me to think I could just update the state, rather than having to move around the whole resource.

But the technique you supplied works!

Thanks!



Donald Nong commented Apr 20 '16, 8:51 p.m. | edited Apr 20 '16, 8:54 p.m.

I did spend some time on finding a way to update the attribute itself only (as in the case of RTC), but did not have much luck.

P.S. The document that you linked is for the data warehouse, while the REST API is used against the RQM live database.


permanent link
Ajith O M (46734) | answered Jan 23 '19, 4:43 a.m.

Please provide the REST API url for GET and PUT operations for getting the state of test plan,test suite,test case and test script and then updating the same.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.