如何在 SoapUI 中获得通过和失败的测试用例计数
How to get passed and failed test case count in SoapUI
我想知道我的测试套件中失败和通过的测试用例总数
我知道我们可以通过 testRunner.testCase.testSuite.getTestCaseCount()
.
获取测试用例总数
我想知道有没有办法让我们可以从 testRunner 中获取所需的东西。
在 SOAPUI 文档中 here 您可以看到以下脚本。您可以使用测试套件视图的 tearDown script
选项卡将代码作为测试套件的 tearDown Script
:
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 }
}
}
}
此脚本记录每个测试用例的名称,如果测试用例失败,则显示断言失败消息。
做完全相同并且计算失败的测试用例总数的更 groovier 脚本可能是:
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"
希望对您有所帮助,
我想知道我的测试套件中失败和通过的测试用例总数
我知道我们可以通过 testRunner.testCase.testSuite.getTestCaseCount()
.
我想知道有没有办法让我们可以从 testRunner 中获取所需的东西。
在 SOAPUI 文档中 here 您可以看到以下脚本。您可以使用测试套件视图的 tearDown script
选项卡将代码作为测试套件的 tearDown Script
:
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 }
}
}
}
此脚本记录每个测试用例的名称,如果测试用例失败,则显示断言失败消息。
做完全相同并且计算失败的测试用例总数的更 groovier 脚本可能是:
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"
希望对您有所帮助,