Forum Discussion

Madhusm's avatar
Madhusm
Occasional Contributor
4 years ago

Centralizing the custom properties defined for Environments. Want to read values from a config file.

We have projects created which has to be executed across N environments. Currently it is quite cumbersome to manually create environments and maintain it. For example I have an environment defined X...
  • nmrao's avatar
    nmrao
    4 years ago

    Just to demonstrate, created a simple project, called testProperties

    - This project contains a single test suite and test case which contains a groovy script test step.

    - The groovy script test step access the project properties. Of course, any test step in the project can access these properties which every knows.

    - Created two property files. These property files are being passed as arguments to testrunner script command line

    -- qa.properties => contains environment details of QA

    -- staging.properties => contains environment details of Staging

    - This is completely handled as out-of-the-box functionality of the tool, so no burden for the user at all.

    - The argument needs to pass is -Dsoapui.properties.<projectName>=<property file path>

    - The projectName in the above is what you see in when the project is opened in the tool. or you can find in the project properties Name field. In my case, my project is named as "testProperties"

    - Here is the excerpt from the command line execution of the project and they show the correct values loaded from the property file. Notice the log statements.

    - You can see the command

    ./testrunner.sh testProperties-soapui-project.xml -Dsoapui.properties.testProperties=qa.properties

     

     

    Attaching the sample project (created in free version for the benefit of SoapUI  tool users as well), so one can try themselves by downloading the artifacts.

     

    https://github.com/nmrao/sample-soapui-projects/tree/master/environmentsExample

     

     

    One can added as many properties required for the each environment in separate file and just pass the respective file when needed.

     

    Of course, one can use Environment feature if there is need and when they have pro tool. I am sure, it must be possible to switch the environment name from the command-line, i am not familiar about that. One should be able find it in the documentation. I am wondering why one need to write the script like what you have.

    ,