I understand that I am a little late for the party, but I thought that I would expand this topic by sending my solution to a similar problem. Hope this helps someone in the future. The solution can be scaled to cover more than two stages of testing, test cases and / or projects. This is also my first post here, so please excuse me for any noob errors. Not the most beautiful solution. It may have some redundant variables. All code blocks contain the entire solution.
Problem: I want to receive answers from two different stages of testing, each in different test cases, in two diff projects, but in the same workspace. Got it? great!
DECISION:
Variables for the first project
String firstProjName = "Generic Project One" String firstProjTestSuiteName= "Generic Test Suite Name One" String firstProjTestCaseName = "Generic Test Case Name One" String firstProjTestStepName= "Generic Test Step Name One"
Variables for the second project
String secondProjName= "Generic Project Two" String secondProjTestSuiteName = "Generic Test Suite Name Two" String secondProjTestCaseName= "Generic Test Case Name Two" String secondProjTestStepName= "Generic Test Step Name Two"
Standard Step Testing Access Name
def firstProj= null def workspace = testRunner.testCase.testSuite.project.getWorkspace(); firstProj= workspace.getProjectByName(firstProjName) def firstTestCase = firstProj.testSuites[firstProjTestSuiteName].testCases[firstProjTestCaseName ] def firstTestStep = firstTestCase.getTestStepByName(firstProjTestStepName)
Run the general test step Name One
def runner = null runner = firstTestStep.run(testRunner, context) def firstTestStepResp = runner.getResponseContent() runner = null
Print response to the magazine
log.info(firstTestStepResp)
The same with the second stage of testing
def secondProj= null secondProj= workspace.getProjectByName(secondProjName) def secondTestCase = secondProj.testSuites[secondProjTestSuiteName ].testCases[secondProjTestCaseName] def secondTestStep = secondTestCase.getTestStepByName(secondProjTestStepName) runner = secondTestStep.run(testRunner, context) def secondTestStepResp = runner.getResponseContent() log.info(secondTestStepResp)
Now we have access to both answers as strings with which we can play, but we want. Compare, tokenize, etc. There is also
getResponseContentAsXml()
if response is required as xml instead of string.