Groovy 如何在SoapUI中获得通过和失败的测试用例计数
我想知道我的测试套件中失败和通过的测试用例的总数 我知道我们可以通过Groovy 如何在SoapUI中获得通过和失败的测试用例计数,groovy,soapui,Groovy,Soapui,我想知道我的测试套件中失败和通过的测试用例的总数 我知道我们可以通过testRunner.testCase.testSuite.getTestCaseCount()获取测试用例总数 我想知道是否有一种方法可以让我们从testRunner获得所需的东西。在SOAPUI文档中,您可以看到下面的脚本。您可以使用TestSuite视图的tearDown Script选项卡将代码作为TestSuite的tearDown Script: 该脚本记录每个testCase的名称,如果testCase失败,则显
testRunner.testCase.testSuite.getTestCaseCount()
获取测试用例总数
我想知道是否有一种方法可以让我们从testRunner获得所需的东西。在SOAPUI文档中,您可以看到下面的脚本。您可以使用TestSuite视图的tearDown Script
选项卡将代码作为TestSuite的tearDown Script
:
该脚本记录每个testCase的名称,如果testCase失败,则显示断言失败消息
一个更为groovier的脚本可以执行完全相同的操作,还可以计算失败的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"
希望有帮助,谢谢你的回答,但我想要一个没有任何拆卸脚本的解决方案。我通过使用suite参数做了一些变通。因为,这个答案是完美的,标记为correct@UdayNaik能否请您发布或解释更多关于套件参数的尝试。
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"