在Groovy Script步骤中运行testcase时显示java.lang.NullPointerException

问题描述 投票:0回答:1

我试图在SoapUI中使用Groovy从Groovy Script TestStep运行TestCase。

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def testCase = testRunner.testCase;
def testStep = testCase.testSteps["CreateMeeting"];
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);

显示错误:

java.lang.NullPointerException

在行发生错误:

testStepContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep);

项目结构:

enter image description here

groovy soapui
1个回答
2
投票

当您调用Groovy测试步骤时,您会获得一些预先声明的变量,例如logcontexttestRunner,因此您不必声明自己的变量。

这对我有用:

//def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def testCase = testRunner.testCase.testSuite.project.getTestSuiteByName("AddBooking").getTestCaseByName("CreateMeeting")
//def testStep = testCase.testSteps["CreateMeeting"]
//testRunner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testCase, null);
//testStepContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep);
def properties = new com.eviware.soapui.support.types.StringToObjectMap ()
testCase.run(properties, false)
© www.soinside.com 2019 - 2024. All rights reserved.