我想知道我的测试套件中失败和通过的测试用例的总数
我知道我们可以通过获取testCases的总数testRunner.testCase.testSuite.getTestCaseCount().
我想知道有没有办法让我们从testRunner获得所需的东西.
在SOAPUI文档中,您可以看到以下脚本.您可以tearDown Script使用tearDown scripttestSuite视图的选项卡将代码作为TestSuite 的代码:
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 }
}
}
}
Run Code Online (Sandbox Code Playgroud)
此脚本记录每个testCase的名称,如果testCase失败,则显示断言失败的消息.
一个更加时髦的脚本完全相同并且还计算testCase失败的总数可能是:
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"
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你,
| 归档时间: |
|
| 查看次数: |
3416 次 |
| 最近记录: |