Ask a Question

Project Load Script executed before the command line arguments are used.

SOLVED
sergeykh
Occasional Contributor

Project Load Script executed before the command line arguments are used.

Hi

I`m using the option to execute the soapUI project from command line and using the P argument to pass project level properites.

 

<Quote>

P : Specifies a value of a project property for the test run. The specified value will override the variable's value during the run. Usage: -P<variable>=<value>. If the value includes spaces, enclose the entire argument in quotes. To override several variable values, specify the -P argument several times.

<End Quote>

 

In the Project Load Script I want to load project level properties from previously saved property file using the ENV_NAME property which is passed in the command line arguments.

The problem that I`ve encountered is that the Project Load Script is executed before the argument from the command line is used to set the ENV_NAME property. As a work around I have added a new testSuite which will run the script instead of the Project Script.

But this seems patchy and also reflects in the test report.

Can someone explain the logic why to run the Project Load Script before the command line arguments were used?

Is there some other way to pass an argument to the project which can be used in the Project Load Script?

 

4 REPLIES 4
JHunt
Community Hero

Seems you could do some creative workaround, such as:

 

test.bat

echo ENV123 > C:\env_name.txt
testrunner "myproject.xml"

Project Load Script:

project.setPropertyValue( "ENV_NAME", new file("C:/env_name.txt").text )
assert project.getPropertyValue("ENV_NAME") = "ENV123"

 

I could have some typo since I haven't run this, but just to give you an idea...

nmrao
Community Hero

Another way to override the properties is to use a property file, change the values as needed for the current test, and pass it for testRunner utility as system argument such as :

-Dsoapui.properties="/path/to/project.properties"


Regards,
Rao.
sergeykh
Occasional Contributor

Thanks for the input.

Used the file solution.

sergeykh
Occasional Contributor

In another post I raised, a better solution was provided.

https://community.smartbear.com/t5/SoapUI-Open-Source/can-I-know-in-the-project-load-Script-if-the-s...

In short, the project properites are set from the command line after project load scirpt is executed.

But the system properties are set before.

So they can be used.

 

testrunner.bas <options to execute the project> -DIS_INVOKED_COMMANDLINE=true

if ('true' == System.getProperty('IS_INVOKED_COMMANDLINE')) {
//You business logic here
}

 

cancel
Showing results for 
Search instead for 
Did you mean: