Forum Discussion

HeikoStudt's avatar
HeikoStudt
Occasional Contributor
9 years ago

Testrunner, Script and "isCommandLine"

[Edit: Clearing up quite a bit]

Hi,

 

I am using the latest SoapUI 5.2.1 with its testrunner.bat

 

Manual steps should be ignored from commandline - at least according to the source code of SoapUI 4.0. However, in latest SoapUI they fail.

 

15:32:09,094 INFO  [SoapUITestCaseRunner] running step [Restart ESB (clear state)]
15:32:09,099 ERROR [AbstractTestRunner] Exception during Test Execution
java.lang.NullPointerException
	at com.eviware.x.form.XFormFactory.createDialogBuilder(XFormFactory.java:21)
	at com.eviware.x.form.support.ADialogBuilder.buildDialog(ADialogBuilder.java:66)
	at com.eviware.x.form.support.ADialogBuilder.buildDialog(ADialogBuilder.java:51)
	at com.eviware.soapui.impl.wsdl.teststeps.ManualTestStep.run(ManualTestStep.java:117)
	at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:211)
	at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:47)
	at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:138)
	at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:46)
	at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:129)
	at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.start(AbstractTestRunner.java:77)
	at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.run(WsdlTestCase.java:595)
	at com.eviware.soapui.tools.SoapUITestCaseRunner.runTestCase(SoapUITestCaseRunner.java:565)
	at com.eviware.soapui.tools.SoapUITestCaseRunner.runRunner(SoapUITestCaseRunner.java:397)
	at com.eviware.soapui.tools.AbstractSoapUIRunner.run(AbstractSoapUIRunner.java:204)
	at com.eviware.soapui.tools.AbstractSoapUIRunner.run(AbstractSoapUIRunner.java:139)
	at com.eviware.soapui.tools.AbstractSoapUIRunner.runFromCommandLine(AbstractSoapUIRunner.java:114)
	at com.eviware.soapui.tools.SoapUITestCaseRunner.main(SoapUITestCaseRunner.java:120)

For circumventing the error, I have tried to write a groovy script which tests whether it is called in commandline or not.

I've got the condition from http://www.soapui.org/scripting---properties/tips---tricks.html.

However, "isCommandLine" is always false in my tests.

 

Groovy Script:

def isCommandLine = com.eviware.soapui.SoapUI.isCommandLine
log.info("isCommandLine:" + isCommandLine)
if (isCommandLine) {
    log.info("in cmdl");
    testRunner.gotoStepByName( "GetStates is Empty" );
}

 

I had a small glimpse on the 4.0 and 5.2.0 source code. I did not find a problem, however.

Luckily, I found there the "isStandalone" static property, which seem to contain the correct information. :-)

 

My question: Is "isStandAlone" the correct property to use nowadays? Did I mistake the isCommandline somehow or is there any known bug?

 

 

MFG (Best regards)
Heiko Studt

7 Replies

  • sburkard's avatar
    sburkard
    Occasional Contributor

    If you want to find out if soapui was called from the GUI or not, you can also check if the workspace is null:

     

    def workspace = testRunner.testCase.testSuite.project.getWorkspace()
    
    if(workspace != null) {
       // called by GUI
    } else {
       // called by command line
    }
  • kondasamy's avatar
    kondasamy
    Regular Contributor

    Didn't noticed this change in particular! Does 'isStandalone' option worked for you instead of 'isCommandLine' option? If yes, does it generated expected outcome?

     

    Thanks,

    Samy

    • HeikoStudt's avatar
      HeikoStudt
      Occasional Contributor

      The "isStandalone" seem to be false for TestRunner and true for SoapUI (GUI).

      However, I did not read the source code for understanding what "isStandalone" should mean, there are no comments whatsoever.

       

       

      MFG (Best regards)
      Heiko Studt

      • kondasamy's avatar
        kondasamy
        Regular Contributor

        So, just to make your code work, you could probably try the below script using 'isStandalone' instead of 'isCommandLine' like this,

         

        if (!isStandalone) {
            log.info("in cmdl");
            testRunner.gotoStepByName( "GetStates is Empty" );
        }

        And I guess the behavior of 'isCommandLine' currently you are experiencing should be a bug!

         

        Thanks,

        Samy