rAJ
rAJ

Reputation: 1433

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 :

java.lang.NullPointerException

Error occured at line :

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

Project Structure :

enter image description here

Upvotes: 0

Views: 1921

Answers (1)

craigcaulfield
craigcaulfield

Reputation: 3538

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)

Upvotes: 2

Related Questions