ReadyAPI - different behaviour for similar elements in groovy script
Hello,
I'm encountering a strange issue as I'm trying to execute a Project A's testCase from a Project B.
If I do the following (code 1) :
tp = testRunner.testCase.testSuite.project.workspace.getProjectByName("DomoveaV2_Service_API") ts = tp.getTestSuiteByName("Domovea V2 API Properties") tc = ts.getTestCaseByName("/m2m/fim/items/{UID}/properties/itemTimestamp") result = tc.run(context.getProperties(),false); log.info "resultat: " + result.status + " - " + result.reason + " - process took " + result.timeTaken + "ms" if (result.status != com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus.OK){ log.info "ko" throw new Exception("Le test distant est FAILED") } else{ return "OK" }
it works. I call a step that fails and I end up with the correct result.
I tried to call it with testRunner but it fails as testRunner doesn't understand Workspaces.
So I found another solution from the community (code 2):
import com.eviware.soapui.impl.wsdl.WsdlProjectPro WsdlProjectPro project = new WsdlProjectPro("C:\\DomoveaV2_Services_API\\package\\DomoveaV2_Service_API-readyapi-project.xml"); //log.info project testSuite = project.getTestSuiteByName("Domovea V2 API Properties") //log.info testSuite testCase = testSuite.getTestCaseByName("/m2m/fim/items/{UID}/properties/itemTimestamp") //log.info testCase result = testCase.run(context.getProperties(),false); log.info "resultat: " + result.status + " - " + result.reason + " - process took " + result.timeTaken + "ms"
But it ends up as FINISHED instead of FAILED !
Has anyone an idea of why this happens ??
Further issue: As I tried to see which was returned for testCase, testSuite, etc. I added the following in the script (code 3):
localProj = testRunner.testCase.testSuite.project.workspace.getProjectByName("DomoveaV2_Service_API") localSuite = localProj.getTestSuiteByName("Domovea V2 API Properties") localTest = localSuite.getTestCaseByName("/m2m/fim/items/{UID}/properties/itemTimestamp") /* log.info "project = " + localProj log.info "testSuite = " + localSuite log.info "testCase = " + localTest */ localResult = testCase.run(context.getProperties(),false); log.info "context = " + context log.info "context properties = " + context.getProperties() log.info "resultat: " + localResult.status + " - " + localResult.reason + " - process took " + localResult.timeTaken + "ms"
Which end up being the same thing as my initial script, but now its ends up as FINISHED !?
So I re-set my initial scripting in the groovy script (so I have code 3 following by code 1) and they produce a different result.
I enabled the logs to check the addresses for project, testsuite and testcase and they are all the same !!
I finally added logs on context after code 1 and code 3 and they show some differences that I don't understand:
Log after code 3:
context = [ThreadIndex:0 , log:org.apache.log4j.Logger@5ca4713e , RunCount:0 , ExecutionID:77c83a39-8dc8-48fd-8ece-5b5290fedc4b] context properties = [ThreadIndex:0 , log:org.apache.log4j.Logger@5ca4713e , RunCount:0 , ExecutionID:77c83a39-8dc8-48fd-8ece-5b5290fedc4b]
log after code 1:
context = [ThreadIndex:0 , StartedByModelItemId:71ef9ee4-d5af-461a-ad0f-76cf0d36eba1 , log:org.apache.log4j.Logger@5ca4713e , RunCount:0 , RecentTestRunsLimit:1 , RunSizeCounter:TestRunSizeCounter{totalSize=43} , ExecutionID:77c83a39-8dc8-48fd-8ece-5b5290fedc4b] context properties = [ThreadIndex:0 , StartedByModelItemId:71ef9ee4-d5af-461a-ad0f-76cf0d36eba1 , log:org.apache.log4j.Logger@5ca4713e , RunCount:0 , RecentTestRunsLimit:1 , RunSizeCounter:TestRunSizeCounter{totalSize=43} , ExecutionID:77c83a39-8dc8-48fd-8ece-5b5290fedc4b]
It seems that, for code 2 and code 3 that the context is not complete ?!
Thanks for any help
Alex