【问题标题】:How to get passed and failed test case count in SoapUI如何在 SoapUI 中获得通过和失败的测试用例计数
【发布时间】:2015-10-20 10:15:14
【问题描述】:

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

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

我想知道有没有办法让我们可以从 testRunner 获得所需的东西。

【问题讨论】:

    标签: groovy soapui


    【解决方案1】:

    在 SOAPUI 文档here 中,您可以看到以下脚本。您可以使用 testSuite 视图的 tearDown script 选项卡将代码作为您的 TestSuite 的 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 }
          }
       }
    }
    

    此脚本记录每个测试用例的名称,并在测试用例失败时显示断言失败消息。

    执行完全相同并计算失败的 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"
    

    希望对你有帮助,

    【讨论】:

    • 感谢您的回答,但我想要一个没有任何拆解脚本的解决方案。我通过使用套件参数做了一些解决方法。因为,这个答案运行良好,将其标记为正确
    • @UdayNaik 您能否发布或解释更多您使用套件参数尝试过的内容。
    猜你喜欢
    • 1970-01-01
    • 2018-12-03
    • 2017-03-27
    • 1970-01-01
    • 2018-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-31
    相关资源
    最近更新 更多