如何使用 groovy 执行 TestSteps?

How to execute TestSteps using groovy?

我在 Soapui 中有一个项目:一个 TestSuite1、TestCase1 和一些 TestStep,例如 Groovy 测试、创建代表和延迟

我想做的是使用 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) 

你有太多同名的 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);