Forum Discussion

mmoser18's avatar
Frequent Contributor
9 years ago

Can one load a properties-file via command-line option?

Is there an option to load specific properties via a command-line option?


We need to test our code in different configurations which require to load different properties-files on top of a common soapUI-project file, i.e. the test-suites and test-cases are the same (or rather: were parameterized) but a couple of top-level properties have to be added/adjusted depending on the configuration to be tested.


I am calling soapUI from our test ant-script in the following way:


 <exec executable="${testrunner.cmd}"
  <arg line="-s ${suite_name} -I -r -i -j -M -f ${reportDir}-${report_name} ${soapUI.project}" />
  <!--  usage: testrunner [options] <soapui-project-file> -->
  <!--   -A   Turns on exporting of all results using folders instead of long filenames -->
  <!--   -a   Turns on exporting of all results -->
  <!--   -c <arg>   Sets the testcase -->
  <!--   -D <arg>   Sets system property with name=value -->
  <!--   -d <arg>   Sets the domain -->
  <!--   -e <arg>   Sets the endpoint -->
  <!--   -f <arg>   Sets the output folder to export results to -->
  <!--   -G <arg>   Sets global property with name=value  -->
  <!--   -H <arg>   Adds a custom HTTP Header to all outgoing requests -->
  <!--     (name=value), can be specified multiple times -->
  <!--   -h <arg>   Sets the host -->
  <!--   -I   Do not stop if error occurs, ignore them -->
  <!--   -i   Enables Swing UI for scripts -->
  <!--   -j   Sets the output to include JUnit XML reports -->
  <!--   -M   Creates a Test Run Log Report in XML format -->
  <!--   -m   Sets the maximum number of TestStep errors to save for each testcase -->
  <!--   -P <arg>   Sets or overrides project property with name=value  -->
  <!--   -p <arg>   Sets the password -->
  <!--   -r   Prints a small summary report -->
  <!--   -S   Saves the project after running the tests -->
  <!--   -s <arg>   Sets the testsuite  -->
  <!--   -t <arg>   Sets the soapui-settings.xml file to use -->
  <!--   -u <arg>   Sets the username -->
  <!--   -v <arg>   Sets password for soapui-settings.xml file -->
  <!--   -w <arg>   Sets the WSS password type, either 'Text' or 'Digest' -->
  <!--   -x <arg>   Sets project password for decryption if project is encrypted -->
  <!-- project file -->



However, that starts soapUI given a specific project file only (which contains a default set of properties) but does not add specific properties to it.


Thus, before running that script I always first need to open the project in soapUI, load the appropriate properties and save the project again (so that the project file now contains the correct default properties). Only then I can run our deploy-and-test-script.


But having to fire up soapUI each time beforehand is cumbersome, easily goes forgotten and partially defeats the purpose of having automated testing.


I know that one can set properties individually (using the -D option as described in the comment above) but we need to set a hole slew of properties each time and I want to avoid having to add these all to my test-script!

6 Replies

  • nmrao's avatar
    Champion Level 3

    If you want project specific properties, still soapui allows to do so using setup script of Project where you can write logic to load the properties from a file with dynamic path using system property (like soapui does, say<filepath> at run time) and then read the file to load properties and set the properties at project level.

    Hope this helps.

    • mmoser18's avatar
      Frequent Contributor

      Thanks! I haven't implemented that, yet, but the idea to pass just a single property as file-namne and the use a script to load the corresponding proeprty-file using a script should get me going.

      • nmrao's avatar
        Champion Level 3

        Not sure if you got what it was already mentioned in the previous reply.

        Keep all your properties in a file called this example, assuming that properties are to be set at project level).

        Anyway, here is the code(can be used in load script for the project, so that automatically loads properties) that can do the same provided is passed as system argument(<property file path>) while invoking soapui or testrunner.


        def props = new Properties()
        new File(System.getProperty("")).withInputStream {
          stream -> props.load(stream)
        props.each {