Ask a Question

Issue in invoking rest method from another test suite using groovy script

ravibabu_it
Occasional Contributor

Issue in invoking rest method from another test suite using groovy script

HI All,

 

I am facing issue where i am unable to invoke rest step that exists in another test suite. When I ran the script, i am always getting "End point url not found". But when I execute the same step directly by clicking Run button it is working fine.

 

Here is the code that i used to invoke rest method from another test suite in same project.

 

ServiceName=context.testCase.testSuite.getPropertyValue("Service")
methodname=context.testCase.testSuite.getPropertyValue("Method")
context.testCase.testSuite.project.testSuites["Services"].testCases[ServiceName].testSteps[methodname].run(null,context)

 

I double checked the values printed in the log and it looks good. Not sure what's wrong with the above step. 

 

 

Please find the attached screenshots which might help in understanding the issue. Any help  is greatly appreciated.

 

 

 

 

7 REPLIES 7
nmrao
Community Hero

Not sure why null is passed to run method.
Can you please try :
..run(testRunner, context)


Regards,
Rao.
ravibabu_it
Occasional Contributor

Thanks RAO for the response . I have tried this earlier and now also  and got the same result.Let me share more details that might help in providing suggestions to this issue.

 

When I invoke the rest method through groovy script, it looks like it is not passing parameter values.

 

 request: GET /DataVisionService/dh/login// HTTP/1.1

DEBUG:Receiving response: HTTP/1.1 404 Not Found

 

But when i execute the same request by clicking run button, it is successfully passing parameters and executing the request correctly.

DEBUG:Sending request: GET /DataVisionService/dh/login/userid/password HTTP/1.1

DEBUG:Receiving response: HTTP/1.1 200 OK

 

Please find the attached screenshot of parameter substitution.

 

Thanks,

Ravindra

Are those are properties set in that test case? or do you need to pass them from here?


Regards,
Rao.
ravibabu_it
Occasional Contributor

I am creating and setting properties values  in the test case during run time..I checked and those properties are set correctly. Manually I have refereed those values in rest method as ${#TestCase#userid} .Please let me know if you need any more information. Thanks once again for looking into the issue.

 

 

myTestCase.setPropertyValue(inputtagList,inputValueList)
def x = myTestCase.getPropertyValue(inputtagList)
log.info " x: $x"

 

Thanks,

Ravindra

Hmm..
Is it possible for you to use "Run Test Case" step instead? Just to see if that is working?


Regards,
Rao.
ravibabu_it
Occasional Contributor

I am not sure how to do that one. Let me research on the syntax and get back to you. Incase if you have syntax handy, please share. Appreciate your support.

ravibabu_it
Occasional Contributor

After I followed the suggestion provided by another user i the forum , it worked like charm. Thank you Rao.

 

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

 

cancel
Showing results for 
Search instead for 
Did you mean: