cancel
Showing results for 
Search instead for 
Did you mean: 

Testrunner, Script and "isCommandLine"

HeikoStudt
Occasional Contributor

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 7
kondasamy
Regular Contributor

Re: Testrunner, Script and "isCommandLine"

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
Occasional Contributor

Re: Testrunner, Script and "isCommandLine"

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
Regular Contributor

Re: Testrunner, Script and "isCommandLine"

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

sburkard
Occasional Contributor

Re: Testrunner, Script and "isCommandLine"

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
}
HeikoStudt
Occasional Contributor

Re: Testrunner, Script and "isCommandLine"


@kondasamy wrote:

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

 

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

 


 

Yes, the workaround with isStandalone is working in my project.

I absolutely agree, that the isCommandLine has to be corrected, as ATM all manual steps will fail in testrunner.bat.

Can someone please point me to the bug tracking system of SoapUI? A quick google search did not find one.

 

 

MFG (Best regards)

Heiko Studt

Tags (2)
kondasamy
Regular Contributor

Re: Testrunner, Script and "isCommandLine"

I don't think you can raise a bug for SoapUI Open Source. But, if you face this issue in SoapUI NG, you can raise a ticket here - http://support.smartbear.com/product-list/

 

Thanks,

Samy

 

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others, Thanks. ↓↓↓

HeikoStudt
Occasional Contributor

Re: Testrunner, Script and "isCommandLine"

By the same bug, the -enableGUI parameter and whatever initGCTImer() does is broken as well. (see below).

 

For the real SoapUI developers: It will fixes plenty of bugs in the Commandline-Testrunner if you fix this issue. Thank you! 🙂

 

 

The problem lies in the AnalyticsHelper:

private static boolean analyticsDisabled() {
        Settings settings = SoapUI.getSettings();

which in turn creates a "DefaultSoapUICore" as there was none initialized before

which in turn sets isCommandLine to false.

 

As the AnalyticsHelper opens some GUI component if you did not enable/disable the analytics before, this is already a bug.

 

However - without analytics - in AbstractSoapUIRunner.run() the isCommandLine field is set twice.

public final boolean run() throws Exception {
        if (SoapUI.getSoapUICore() == null) {
            SoapUI.setSoapUICore(createSoapUICore(), true);
            SoapUI.initGCTimer();
        }

createSoapUICore() creates the DefaultSoapUICore which will set isCommandLine to false.

setSoapUICore is resetting to true just afterwards...

 

 

In my uninformed opinion the bug was inserted as the analytics were put inside. As I hate those analytics anyway, I will disable it in my source permamently... 🙂

 

11:01:35,949 INFO  [log] isCommandLine:true
11:01:35,951 INFO  [log] isStandalone:false

 

Voilà! 🙂

 

 

 

MFG
Heiko Studt

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors