3
失败的测试用例数,我想知道在我的测试套件如何获得通过,并在了SoapUI
我知道我们可以通过testRunner.testCase.testSuite.getTestCaseCount()
获取测试用例总数的失败,并通过测试用例的总数。
我想知道有没有办法让我们从testRunner中获得所需的东西。
失败的测试用例数,我想知道在我的测试套件如何获得通过,并在了SoapUI
我知道我们可以通过testRunner.testCase.testSuite.getTestCaseCount()
获取测试用例总数的失败,并通过测试用例的总数。
我想知道有没有办法让我们从testRunner中获得所需的东西。
在SOAPUI文档here中可以看到下面的脚本。
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 }
}
}
}
这个脚本记录每个测试用例的名称,并在情况下,该测试用例失败显示:您可以使用测试套件视图的tearDown script
标签把代码为你的TestSuite的tearDown Script
断言失败的消息。
更更巧妙的脚本来完成完全相同,也算测试用例总数不合格可能是:
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"
希望它能帮助,
感谢您的回答,但我想一个解决方案,而任何拆卸脚本。我通过玩套件参数做了一个小小的解决方法。因为,这个答案是完美的,标记为正确的 –
@UdayNaik你可以请张贴或解释更多你尝试套房参数。 – sathya