繁体   English   中英

如何使用Groovy脚本在每个UI中启用/禁用soapUI中的测试步骤(在每个测试用例中)基于用户要启用或禁用的测试步骤

[英]How to Enable /Disable test step in soapUI using Groovy script ( inside each test cases) Based on which test step user wanted to enable or disable

如何使用Groovy脚本(在每个测试用例中)在soapUI中启用/禁用测试步骤(基于每个测试步骤用户要启用或禁用)。
喜欢:

  • 如果我有一个测试用例,而那个测试用例有10个步骤。 我只想执行那些以Online开头的测试用例。
  • 如果我有一个测试用例,而那个测试用例有10个步骤。 我只想执行以Batch开头的那些测试用例。

请在下面的示例中查找抛出错误的示例:
Sat May 20 11:35:14 CEST 2017:ERROR:An error occurred [java.lang.NullPointerException], see error log for details while executing the next test cases.

码:

context.testCase.testSuite.getTestCaseList().each
 {
    log.info "Test Case : ${it.name}".toUpperCase();
    it.testStepList.each 
    {
           log.info "Test Step--> : ${it.name}"

         def testStep = testRunner.testCase.getTestStepByName( "${it.name}" 
         log.info testStep.disabled
         if( testStep.disabled )
         {
            testStep.disabled = false

         }

      testRunner.testCase.getTestStepByName("${it.name}").setDisabled(true)
            log.info testStep.disabled
            log.info "Action Perfomed for Test Step : ${it.name}"

    }
 }

在您的代码示例中, def testStep = testRunner.testCase.getTestStepByName( "${it.name}"是不必要的。它将在testSuite中查找包含您运行的脚本的特殊名称的testStep,该脚本不存在,您会收到一个NullPointer异常,可以将其替换为“ it”

context.testCase.testSuite.getTestCaseList().each
{
    log.info "Test Case : ${it.name}".toUpperCase();
    it.testStepList.each 
    {
         log.info "Test Step--> : ${it.name}"

         log.info it.disabled
         if( it.disabled )
         {
            it.disabled = false
         }

        it.setDisabled(true)
        log.info it.disabled
        log.info "Action Perfomed for Test Step : ${it.name}"
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM