如何在SoapUI中通过并且失败的测试用例计数 [英] How to get passed and failed test case count in SoapUI
问题描述
我想知道测试套件中失败和通过的测试用例的总数。我知道我们可以通过 testRunner.testCase.testSuite.getTestCaseCount()
。
我想知道有没有办法让我们可以从testRunner。
在SOAPUI文档中
for testCaseResult in runner.results)
{
testCaseName = testCaseResult.getTestCase()。name
log.info testCaseName $ b $ if(testCaseResult.getStatus()。toString()==' (testCaseResult.getResults())中的testStepResult)
{
testStepResult.messages.each())
{
log.info$ testCaseName has failed
){msg - > log.info msg}
}
}
}
脚本会记录每个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失败
testCaseResult.results.each {testStepResults - >
testStepResults.messages.each(){msg - >
}其他$ {
log.info$ name正常工作
}
}
log。 infototal failed:$ failedTestCases
希望它有帮助,
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.getTestCaseCount()
.
I want to know is there a way so that we can get the required thing from testRunner.
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,
这篇关于如何在SoapUI中通过并且失败的测试用例计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!