gpt4 book ai didi

groovy - 如何在 SoapUI 中获取通过和失败的测试用例计数

转载 作者:行者123 更新时间:2023-12-02 06:40:31 25 4
gpt4 key购买 nike

我想知道我的测试套件中失败和通过的测试用例的总数

我知道我们可以通过 testRunner.testCase.testSuite.getTestCaseCount() 获取测试用例总数。

我想知道有没有一种方法可以让我们从 testRunner 获取所需的东西。

最佳答案

在 SOAPUI 文档中 here你可以看到下面的脚本。您可以使用 testSuite View 的 tearDown script 选项卡将代码作为 TestSuite 的 tearDown Script 放置:

enter image description 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 }
}
}
}

此脚本记录每个测试用例的名称,如果测试用例失败,则会显示断言失败消息。

一个更常规的脚本可以执行完全相同的操作并计算失败的测试用例总数:

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"

希望对你有帮助

关于groovy - 如何在 SoapUI 中获取通过和失败的测试用例计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33233938/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com