Forum Discussion

sburkard's avatar
sburkard
Occasional Contributor
10 years ago

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

 

  • 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()

     

  • sburkard's avatar
    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's avatar
      kondasamy
      Regular Contributor

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

       

      -Samy

  • kondasamy's avatar
    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

     

    • sburkard's avatar
      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's avatar
        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