Forum Discussion
While this is not eaxctly what you asked, here is a project teardown script that iterates through all of its test suites, cases, and steps to get the results, this may point you in the right direction.
log.info('Project ' + runner.getProject().getName() + ' TestRunner.Status = ' + runner.getStatus())
runner.getResults().each{ testSuiteRunner ->
log.info('Test Suite ' + testSuiteRunner.getTestSuite().getName() + ' TestRunner.Status = ' + testSuiteRunner.getStatus())
testSuiteRunner.getResults().each{ testCaseRunner ->
log.info('Test Case ' + testCaseRunner.getTestCase().getName() + ' TestRunner.Status = ' + testCaseRunner.getStatus())
testCaseRunner.getResults().each{ testStepResult ->
log.info('Test Step ' + testStepResult.getTestStep().getName() + ' TestStepResult.TestStepStatus = ' + testStepResult.getStatus())
}
}
}
Take a look at the TestRunner interface and it various subinterfaces for more information.
The following post:
Details how to deal with test steps that do not have assertions (eg groovy test step)
As for messages, the TestStepResult has a getMessages() method that returns an array of strings, you could add in something to the processing of the test step results above like:
// Assumes you've already defined the variable testStepResult
if(testStepResult.getStatus().toString() != 'OK' ){ testStepResult.getMessages().each{ message -> log.error('message = ' + message) } }
- ripplegupta10 years agoContributor
Thanks for answering Radford.
That gives me hint and groovy test step returns empty on runner.status for each previous test step.
So i made 1 event handler that will access test step results and do further actions ..