Forum Discussion

sergeykh's avatar
sergeykh
Occasional Contributor
7 years ago
Solved

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?

 

  • 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...

4 Replies

  • JHunt's avatar
    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's avatar
    nmrao
    Champion Level 3
    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"
  • sergeykh's avatar
    sergeykh
    Occasional Contributor

    Thanks for the input.

    Used the file solution.