【问题标题】:Skip Test Step in SOAPUI through groovy通过 groovy 跳过 SOAPUI 中的测试步骤
【发布时间】:2013-09-30 12:07:22
【问题描述】:

我的测试用例从 Groovy 测试步骤开始,然后是属性和 4 个 SOAP 请求测试步骤。在常规测试步骤中,我执行这些 SOAP 请求,从属性测试步骤访问数据。

在这里,我只想从 groovy 测试步骤执行那些 SOAP 请求。当我在执行 groovy 测试步骤后在 SOAPUI 中将它作为测试用例运行时,这 4 个 SOAP 请求也被执行,我的测试用例失败了。

我使用testRunner.cancel("Skip the Teststep") 它可以跳过那些测试步骤,但它导致执行报告失败,我找不到任何使用 groovy 跳过测试步骤的方法。

请在这方面帮助我。

问候, 马丹

【问题讨论】:

    标签: groovy soapui


    【解决方案1】:

    在 Groovy 脚本步骤中试试这个。

    testRunner.testCase.testSteps.each{k, v ->  
        if(k in ['step1', 'step2']) 
            v.cancel()
    }
    

    其中step1step2 是您要跳过的步骤。

    【讨论】:

    • 我正在尝试使用以下脚本以类似的方式取消测试套件的执行。但它不起作用。我错过了什么吗? testRunner.testCase.testSuite.project.testSuites.each{k, v -> testRunner.cancel(k); }
    【解决方案2】:

    如果您想取消所有测试步骤,请使用

    testRunner.testCase.testSteps.each{k, v ->    
    testRunner.cancel(k)
    

    如果要禁用测试步骤

    def testSuite = context.testCase.testSuite;
    def totalTestCases = testSuite.getTestCases().size();
    
    for(n in (0..totalTestCases-1))
    {    
         testSuite.getTestCaseAt(n).setDisabled(true)
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多