首页 文章

通过groovy跳过SOAPUI中的测试步骤

提问于
浏览
2

我有测试用例从Groovy测试步骤开始,然后是属性和4个SOAP请求测试步骤 . 在groovy测试步骤中,我执行那些SOAP请求,从属性Test步骤访问数据 .

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

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

请帮帮我这个 .

此致,Madhan

2 回答

  • 0

    在Groovy Script步骤中尝试此操作 .

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

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

  • 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)
    }
    

相关问题