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

时间:2017-12-20 19:41:27

标签: groovy soapui

我试图在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

1 个答案:

答案 0 :(得分: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)