Ask a Question

Obtain arguments given to testrunner.sh in Script

SOLVED
sburkard
Occasional Contributor

Obtain arguments given to testrunner.sh in Script

Hi 

 

Is there a way to obtain the arguments given to testrunner.sh? For example the endpoint from the -e option or the username from the -u option?

 

I found in the JavaDoc that the class AbstractSoapUITestRunner has methods to obtain all these values, but I didn't found a way to get them from a Groovy script inside the project that is executed. 

 

Thanks 

Stephan

 

9 REPLIES 9
kondasamy
Regular Contributor

I guess you should use - com.eviware.soapui.tools.SoapUITestCaseRunner as I could see direct call made in the testrunner.sh/ bat file,

 

rem ********* run soapui testcase runner ***********
"%JAVA%" %JAVA_OPTS% com.eviware.soapui.tools.SoapUITestCaseRunner %*

Also, I see the respective mapping methods related to the command line switches. For example,

  • -e - setEndpoint()
  • -u - setUsername()
  • -p - setPassword()

and more on this list..

 

Please check and let us know if this calrifies you.

 

Thanks,

Samy

 

kondasamy
Regular Contributor

Additionally, here is the reference for a sample code which uses SoapUITestCaseRunner while integrating with JUnit. You can make use of this code to refer while running in SoapUI,

http://www.soapui.org/test-automation/junit/junit-integration.html

 

Thanks,

Samy

sburkard
Occasional Contributor

Hi Samy

 

Yeah, I noticed that, but the question is: how can I access the SoapUITestCaseRunner class from a Groovy Script teststep? Where do I get the instance that is created through testrunner.sh from? 

 

The given testrunner variable in the script is of type TestCaseRunner and it doesn't know the getEndpoint method. I also tried via static reference to SoapUI class, but didn't find a way through to SoapUITestCaseRunner.

 

Or am I looking at the wrong place? Do I need to access it in another type of script (like load script or setup script)?

 

Regards

Stephan

 

kondasamy
Regular Contributor

I could able to run using the SoapUITestCaseRunner class and even I was able to successfully work on the switches that we pass through command line. Just for instance, I scripted my code like this in a Groovy Test step,

import com.eviware.soapui.tools.SoapUITestCaseRunner
SoapUITestCaseRunner runner = new SoapUITestCaseRunner()
runner.setProjectFile( "E:\\Official\\Google Maps REST\\Google-Maps-soapui-project - REST XML.xml")
runner.setPrintReport(true)
runner.run()

Thanks,

Samy

sburkard
Occasional Contributor

Hi Samy

 

I'm not sure if we talk abound the same thing. I run a soapui project through commandline with the shell script testrunner.sh. This look somehow like this 

 

 

soapui/bin/testrunner.sh -eMyEndpoint -uUsername mySoapuiProjectfile.xml

 

Now the project mySoapuiProjectfile.xml is executed and inside this project (in a Groovy TestStep of a testcase for example) I would like to find out what was passed as endpoint with the -e switch. 

 

Your code on the other side executes a project (what is in my case already done by calling the testrunner.sh on the command line. So I don't see how your code snippet is related to my question. 

 

Sorry, perhaps I am missing something completely

Stephan

nmrao
Champion Level 3

See if this is useful(replace the Test Request name as needed)

 

log.info testRunner.testCase.testSteps["Test Request"].httpRequest.endpoint


Regards,
Rao.
sburkard
Occasional Contributor

Hi nmrao

 

Unfortunately not. It returns the currently set endpoint on the given Test-Request step (the one shown in the GUI when I open the step).

 

When I call the project from CLI with another endpoint (using -e), I still get the same endpoint instead of the passed one.

 

Stephan

sburkard
Occasional Contributor

OK I finally found it. 

 

I can obtain the runner instance through the statically accessible SoapUI class. I already tried this, but I must have overseen the getCmdLineRunner method that does the trick. 

 

import com.eviware.soapui.SoapUI

def runner = SoapUI.getCmdLineRunner()
assert runner != null

log.info runner.getEndpoint()
log.info runner.getUsername()

 

kondasamy
Regular Contributor

Glad that you found the solution! Thanks for sharing the solution!

 

-Samy

cancel
Showing results for 
Search instead for 
Did you mean: