Forum Discussion

pyrinoff's avatar
pyrinoff
New Contributor
5 years ago

Groovy/scripts: How to call test case and how to send REST request

Hi there! 

I have two questions about soapUI Pro scripting (using now v5.1):

 

1) I trying to launch test case from another test case / mock, but got error 

 

Wed Mar 04 11:52:38 MSK 2020:INFO:Error: groovy.lang.MissingMethodException: No signature of method
Script1.$() is applicable for argument types: (Script1$_run_closure1) values: [Script1$_run_closure1@40aa66fd]
Possible solutions: is(java.lang.Object), run(), run(), any(), use([Ljava.lang.Object;), any(groovy.lang.Closure)

Code:

 

 

log.info('Started')
def currentProject = testRunner.getTestCase().testSuite.getProject();
def theTestCase = currentProject.getTestSuiteByName("TS").getTestCaseByName("TC_send_req");
log.info('Test case: '+theTestCase.getName());

def properties = new com.eviware.soapui.support.types.StringToObjectMap();
def async=false;

 def runner = theTestCase.run(
 	properties,
 	async
 );

log.info('Status: '+runner.status.toString());

if( runner.status.toString() == "FINISHED" ) log.info('Done!');
else log.info("Error: " + runner.reason);

Please help me to fix it, spent hours but no luck

 

 

2) Can i form and send REST request manually? In guide i found this 

request.submit( new com.eviware.soapui.impl.wsdl.WsdlSubmitContext( request ), false )

It's worked for me, but it's SOAP request, and i need to send REST. 

Tried to make test case, add REST request (with endpoint already setted) and call it from groovy, but failed (see question 1).

 

Thank you!