I want to know the total number of failed and passed test cases in my test suite
I know we can fetch total number of testCases by testRunner.testCase.testSuite
In SOAPUI documentation here you can see the follow script. You can put the code as a tearDown Script
of your TestSuite using the tearDown script
tab of your testSuite view:
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 }
}
}
}
This script logs the name of each testCase, and in case that the testCase fail show the assertion failed messages.
A more groovier script to do exactly the same and also counts the total number of testCase failed could be:
def failedTestCases = 0
runner.results.each { testCaseResult ->
def name = testCaseResult.testCase.name
if(testCaseResult.status.toString() == 'FAILED'){
failedTestCases ++
log.info "$name has failed"
testCaseResult.results.each{ testStepResults ->
testStepResults.messages.each() { msg -> log.info msg }
}
}else{
log.info "$name works correctly"
}
}
log.info "total failed: $failedTestCases"
Hope it helps,