我想知道我的测试套件中失败和通过的测试用例的总数
我知道我们可以通过以下方式获取测试用例的总数testRunner.testCase.testSuite.getTestCaseCount()
.
我想知道有没有一种方法可以让我们从 testRunner 获得所需的东西。
在 SOAPUI 文档中here你可以看到下面的脚本。您可以将代码作为tearDown Script
你的 TestSuite 使用tearDown script
testSuite 视图的选项卡:
![enter image description here](https://i.stack.imgur.com/WXa3f.png)
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 }
}
}
}
该脚本记录每个测试用例的名称,并在测试用例失败时显示断言失败消息。
一个更常规的脚本可以执行完全相同的操作并计算失败的测试用例总数:
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"
希望能帮助到你,
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)