0
votes

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

1
hard to understand the reason just by error message. better to provide full stacktrace. I guess that testStep is null at this point. but with stacktrace possible to identify the real problem. - daggett
Are they both on same test suite? what is your use case? why do you want to run a test case from other test case? Best thumb rule is that each test case is independent. Would you mind to show, may be with the help of screen shot, how the test case / steps are located / structured in different cases? - Rao
Yes they are in same suite. Actully i am using Groovy Script teststep to generating variable at runtime and store it to project level properties. Then at last calling the testcase. Attaching the Project structure screenshot. - rAJ
Thank you for the update. Any specific reason for having that single step in a different test case? Can't you have both in steps in the same test case? - Rao
There is a For loop in 'CreateRoombooking' teststep so I want to run 'CreateMeeting' testCase each time when my values changes. - rAJ

1 Answers

2
votes

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)