Forum Discussion

richie's avatar
richie
Community Hero
5 years ago
Solved

Load project level properties file using groovy?

Hey,

I was wondering if its possible to use groovy to load a properties file containing project level properties?

I found a post nmrao answered (e.g. https://community.smartbear.com/t5/SoapUI-Open-Source/Loading-properties-from-file-via-Groovy/td-p/44058) and the way i interpret the response means you can load testcase level props (via a testcase level setup script) bit not project level props via groovy.

Is that correct....you cant load a project level props file via groovy?

Cheers,

Rich
  • If I understand right, you came up with based on the environment related question.

    One can load the properties easily from UI. Of course, it is also possible to load from the script as well, but that requires property file path as input, at least needs to be changed. So, loading thru UI is very simple.

    By the way, SoapUI / ReadyAPI loads the properties file by default, but the name and location are fixed.
    Before invoking the tool, place the specific env properties into soapui.properties located under SOAPUI_HOME/bin; those properties automatically loaded.

    If you still want script, then use same code at Project Setup script with below change. But you need to deal with property file path for that. Currently it was referring to Test case level.

    Change from
    testCase.setPropertyValue(it.key,it.value)

    To
    project.setPropertyValue(it.key,it.value)

2 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    If I understand right, you came up with based on the environment related question.

    One can load the properties easily from UI. Of course, it is also possible to load from the script as well, but that requires property file path as input, at least needs to be changed. So, loading thru UI is very simple.

    By the way, SoapUI / ReadyAPI loads the properties file by default, but the name and location are fixed.
    Before invoking the tool, place the specific env properties into soapui.properties located under SOAPUI_HOME/bin; those properties automatically loaded.

    If you still want script, then use same code at Project Setup script with below change. But you need to deal with property file path for that. Currently it was referring to Test case level.

    Change from
    testCase.setPropertyValue(it.key,it.value)

    To
    project.setPropertyValue(it.key,it.value)
    • richie's avatar
      richie
      Community Hero

      Hey nmrao 

       

      Yep!

       

      I'm always gonna listen to advice fella - I just wanted the most efficient way of loading the properties and I thought a script would do it.

       

      Appreciate all the help,

       

      nice one,

       

      rich