Create new Execution Result in RQM using Rest API
I am also facing similar issue. What we do is we go and create Execution Record for all test cases that needs to be executed on a build. Please note that while creating execution record we don't create the Execution Result, to so initially all the test cases as Not Run. Now We run our Automation framework which executes the test cases and updates the execution result in RQM.
We use rest API to create Execution result.
First issue is while setting the Testplan, Testcase, TestPhase etc. executionResult.setTestcase(testcase)
here it asks for a testcase instance of ...bind.ExecutionResult.Testcase class.
and I am unable to get the reference of this inner class. If I try to get the reference from the Test Execution Record it gives ...bind.Executionworkitem.Testcase
similarly for testplan and Testphase.
If any one can tell how to get reference of testcase, testphase, testplan without using another Execution Result.
Second way What I tried is
Created a Execution Record with using same testplan, testphase and testenvironment
In this case as we know RQM will not create a new Execution record instaed it will create a Execution Result and attach this to same execution record which has all 3 parameters(testplan, testphase, testenvironment) same.
In this case I get an error "Redirect requested but followRedirects is disabled."
I tried to setfollowRedirects on IRQMRestClient but didn't find any method how to do this.
If anyone can help me in any of these 2 issues, it will be highly appreciated.
We use rest API to create Execution result.
First issue is while setting the Testplan, Testcase, TestPhase etc. executionResult.setTestcase(testcase)
here it asks for a testcase instance of ...bind.ExecutionResult.Testcase class.
and I am unable to get the reference of this inner class. If I try to get the reference from the Test Execution Record it gives ...bind.Executionworkitem.Testcase
similarly for testplan and Testphase.
If any one can tell how to get reference of testcase, testphase, testplan without using another Execution Result.
Second way What I tried is
Created a Execution Record with using same testplan, testphase and testenvironment
In this case as we know RQM will not create a new Execution record instaed it will create a Execution Result and attach this to same execution record which has all 3 parameters(testplan, testphase, testenvironment) same.
In this case I get an error "Redirect requested but followRedirects is disabled."
I tried to setfollowRedirects on IRQMRestClient but didn't find any method how to do this.
If anyone can help me in any of these 2 issues, it will be highly appreciated.
4 answers
1) You need to create a new instance of Executionresult.Testcase and set the properties. For example:
Executionresult.Testcase jaxbTestcase = new Executionresult.Testcase();
jaxbTestcase.setXXX();
jaxbExecutionresult.setTestCase(jaxbTestcase);
2) You need to disable follow redirects on the HTTP method before execution:
putOrPostHttpMethod.setFollowRedirects(false);
//Execute HTTP method...
To resolve the execution work item URL:
if(putOrPostHttpMethod.getStatusCode() == HttpURLConnection.HTTP_MOVED_TEMP){
String location = putOrPostHttpMethod.getResponseHeader(HTTP_HEADER_LOCATION).getValue();
}
Executionresult.Testcase jaxbTestcase = new Executionresult.Testcase();
jaxbTestcase.setXXX();
jaxbExecutionresult.setTestCase(jaxbTestcase);
2) You need to disable follow redirects on the HTTP method before execution:
putOrPostHttpMethod.setFollowRedirects(false);
//Execute HTTP method...
To resolve the execution work item URL:
if(putOrPostHttpMethod.getStatusCode() == HttpURLConnection.HTTP_MOVED_TEMP){
String location = putOrPostHttpMethod.getResponseHeader(HTTP_HEADER_LOCATION).getValue();
}
Comments
Thanks Paul for your reply
When I post, it gives error "Test Case Execution Record is not provided" I am unable to get the href of Executionworkitem to do something like this Executionresult.Executionworkitem execResWI = new Executionresult.Executionworkitem(); execResWI.setHref("I need href of Execution record to set here"); executionResult.setExecutionworkitem(execResWI );
I don't have any existing ExecutionResult. I have only Execution record.
I created a new Executionresult.Executionworkitem
created a href based on webId of Executionworkitem that I want to update and set that in newly created Executionresult
after that post the Executionresult
I get Null pointer exception from post method, but execution result is created.
If any one has any idea why Null pointer is coming, which parameter I need to set to remove this.
created a href based on webId of Executionworkitem that I want to update and set that in newly created Executionresult
after that post the Executionresult
I get Null pointer exception from post method, but execution result is created.
If any one has any idea why Null pointer is coming, which parameter I need to set to remove this.