Forum Discussion

krogold's avatar
krogold
Regular Contributor
6 years ago

dynamic setting of preferences

Hello,

I have a set of groovy scripts set as an external library in my project.

those scripts are located in /my_project/scripts/groovy

When I play my tests via the testRunner, the methods are not found as Preference scripts settings in "ReadyAPI 2.7.0/bin/scripts

I tried to modify dynamically this setting as my test can be executed from different computers, I use the following:

def scripts_path = context.expand( '${#Project#scripts_path}' )

settings = com.eviware.soapui.SoapUI.settings


project = testRunner.testCase.testSuite.project
project.setScriptLibrary(scripts_path)
log.info "project script library : " + project.scriptLibrary // => to check setting is correct

settings.setString( "Script Library", ""); // clear settings
log.info "init pref : " + com.eviware.soapui.SoapUI.settings.getString( "Script Library","default")
settings.setString( "Script Library", scripts_path);
log.info "get pref : " + com.eviware.soapui.SoapUI.settings.getString( "Script Library","default") // => to check setting is correct

Log shows that the path for scripts is the one expected, though it still raises errors.

 

In my soapui-settings.xml (user) I can see that the script library path is not the one expected.

It seems that SOAPUI does not take into account the dynamic change of preference and uses the static value to get the groovy scripts.

 

Is my method of dynamic setting wrong ? I will configure my soapui-settings with the wanted path as a workaround but it's not a correct solution as it may change

 

--- LATEST info :

If I use the testRunner from the application, it works though it does not work if I use testRunner from a TFS build.

If I close the application, then I can see that the Script Library path, in soapui-settings.xml, has been updated with the correct path (though it was not visible in the Preference/ReadyAPI tab of the application !!), after that the TFS build finds the scripts and execution is correct : this shows that testRunner uses only the static definition from soapui-settings and does not allow dynamic settings of Preferences, this is not sustainable as, in my case, TFS builds can load sources in a different path, which would invalidate the current scripts path

 

 

thanks for any help

 

Alexandre

  • Well, as a solution I opened the UI in the distant computer, set the proper path and exited UI. It saved the settings and now I can use them.

    It will probably be enough but I'll have to do it again on next readyAPI version upgrade.

     

    I'll try with nmrao solution of handling separate settings it will be a sustainable solution

     

    thanks for your help

     

    Alex

  • nmrao's avatar
    nmrao
    Champion Level 3
    It is good and possible to set the configuration changes dynamically.
    One more thing can be done. it is also not a bad choice to change the settings thru SoapUI / ReadyAPI tool and save these settings into separate copy (you can have multiple settings file)and use this file while running the tests from command line testrunner utility and it takes settings file as parameter. You can try it.
    • krogold's avatar
      krogold
      Regular Contributor

      Well, as a solution I opened the UI in the distant computer, set the proper path and exited UI. It saved the settings and now I can use them.

      It will probably be enough but I'll have to do it again on next readyAPI version upgrade.

       

      I'll try with nmrao solution of handling separate settings it will be a sustainable solution

       

      thanks for your help

       

      Alex

      • nmrao's avatar
        nmrao
        Champion Level 3
        I do not think settings file is required to change per new version. Was it the case that you experienced?
  • nmrao's avatar
    nmrao
    Champion Level 3
    Can't possible to place the scripts in default location? Do they work if you do so?
    • krogold's avatar
      krogold
      Regular Contributor

      it is possible, and they work, but it is not sustainable for Continuous Integration as it is not in my repository, so if they are modified, they won't be downloaded automatically. In that case I will have to copy them manually or to build a script that will copy them automatically ...

      • nmrao's avatar
        nmrao
        Champion Level 3
        Where did you place the above mentioned script?