Forum Discussion
- FinanFrequent ContributorI changed the script into the following:
import com.eviware.soapui.impl.wsdl.panels.support.MockTestRunner
int count = testSuite.getTestCaseCount()
for(i = 0; i < count; i++)
{
testCase = testSuite.getTestCaseAt(i)
testRunner = new MockTestRunner(testCase)
for (result in testRunner.getResults())
{
log.info result.getStatus()
}
}
But this doesn't return anything:( - SmartBear_SuppoSmartBear Alumni (Retired)Hi!
From the TestSuite scope, the test runner is referenced as runner, whereas it's referenced as testRunner in the TestCase scope. The naming discrepancy is because of legacy reasons. We should change this in the future (I've added it to our backlog).
Tips: The available variables in a script is always shown in the upper right corner:
Regards!
/Henrik
eviware.com - FinanFrequent Contributorah ok, that explains it a bit.....
so on the testSuite.tearDownScript level the following script returns the results from each testCase:for(result in runner.results)
{
log.info result.getStatus()
}
1. In case a testCase has failed, I'd like to know which testStep has failed. How do I script this?
2. For each testCase that returns a FAILED status, I also want to know the results from each testStep. Again, how to script this?
I tried the following, did not work:(for(result in runner.results)
{
log.info result.getTestCase().name
if(result.getStatus().toString() == 'FAILED')
{
log.info "TestCase has failed"
for(a in result.getTestCase.results())
{
log.info a
}
}
} - SmartBear_SuppoSmartBear Alumni (Retired)Hi Finan,
This should work:for( testCaseResult in runner.results )
{
testCaseName = testCaseResult.getTestCase().name
log.info testCaseName
if( testCaseResult.getStatus().toString() == 'FAILED' )
{
log.info "$testCaseName has failed"
for( testStepResult in testCaseResult.getResults() )
{
testStepResult.messages.each() { msg -> log.info msg }
}
}
}
I've added it to the Scripting Tips & Tricks page.
/Henrik
eviware support- harish4b4Senior Member
When I use above code...It is printing results in random order.
i.e let say i have test cases named with A,B and C in order..when I run above code multiple times it prints results in random order like C,A,B or B,A,C.
In order to prepare Customized HTML reports i want to access results in order.Can some one give solution ASAP.
Thanks in advance.
- FinanFrequent ContributorHi,
Thx for the script! It gave me enough clues to solve this part of my scripting puzzle - gicoprasicoNew Contributor
Did you try: testRunner.testCase.name
Related Content
Recent Discussions
- 21 days ago