rAJ rAJ - 5 months ago 79
Groovy Question

java.lang.NullPointerException displayed when run testcase inside Groovy Script step

I am trying to run TestCase from Groovy Script TestStep using Groovy in SoapUI.

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);

Error displayed :


Error occured at line :

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

Project Structure :

enter image description here

Answer Source

When you invoke a Groovy test step you get a number of variables pre-declared such as log, context, and testRunner, so you don't have to declare your own.

This worked for me:

//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)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download