我在Soapui有一个项目:TestSuite1,TestCase1和一些TestStep,如Groovy测试,创建Rep和延迟
我想要做的是使用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)
答案 0 :(得分:6)
你有太多的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);