【问题标题】:How to execute TestSteps using groovy?如何使用 groovy 执行 TestSteps?
【发布时间】:2015-01-19 14:57:03
【问题描述】:

我在 Soapui 有一个项目:TestSuite1、TestCase1 和一些 TestStep,如 Groovy 测试、Create Rep 和 Delay

我想要做的是使用 groovy 执行 Create Rep TestStep。 我试过这个:

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def testCase = testRunner.testCase;
def testStep = testCase.getTestStepAt(0);
def testStep = testCase.getTestStepByName("Create Rep");
def testStep = testCase.testSteps["Delay"];
testRunner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testCase, null);
testStepContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep);
testStep.run(testRunner, testStepContext);

我得到了这个错误:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script15.groovy: 27:
   The current scope already contains a variable of the name testStep @ line 27, column 5.
      def testStep = testCase.getTestStepByName("");
          ^ org.codehaus.groovy.syntax.SyntaxException: The current scope already contains a variable of the name testStep @ line 27, column 5.
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:146) 

【问题讨论】:

    标签: groovy soapui


    【解决方案1】:

    你有太多的 testStep 变量具有实际相同的名称

    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
    def testCase = testRunner.testCase;
    def testStep1 = testCase.getTestStepAt(0);
    def testStep2 = testCase.getTestStepByName("Create Rep");
    def testStep3 = testCase.testSteps["Delay"];
    testRunner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testCase, null);
    testStepContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep);
    testStep.run(testRunner, testStepContext);
    

    【讨论】:

    • 在 testStepContext 上出现错误 = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep);没有这样的属性 testStep
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-11
    • 2017-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-05
    • 1970-01-01
    相关资源
    最近更新 更多