Forum Discussion

bmgriner's avatar
bmgriner
Frequent Contributor
14 years ago

Dynamic Script Library Location

I noticed in the project properties there is one called Script Library. When I try to set this with a dynamic value, such as
${projectDir}/[name_of_composite_project]/scripts
my scripts are not loading correctly. I checked that the correct value was in the project object by doing
log.info(project.scriptLibrary)
. It returned the same value as above. My only other conclusion can be that the property expansion is not happening on this field and thus SoapUI cannot find that path. I have tried using the absolute path and it worked correctly. The scripts could be run.

Am I missing anything?

8 Replies

  • MHolmqvist's avatar
    MHolmqvist
    Occasional Contributor
    After some experimenting I found out that you can do the following in Project load script to achieve the same:
    // Set script library
    def header="Project ${project.name} load script:"
    def scriptLibrary = context.expand('${projectDir}')+"\\soapui_groovy_scripts";
    log.info "${header} Setting project Groovy script library to "+scriptLibrary
    project.setScriptLibrary(scriptLibrary)
    log.info "${header} project.scriptLibrary="+project.getScriptLibrary()

    //Make sure global setting is cleared
    log.info "${header} Clearing global script library."
    com.eviware.soapui.SoapUI.settings.setString( "Script Library", "");
    log.info "${header} Global scriptLibrary='"+com.eviware.soapui.SoapUI.settings.getString( "Script Library","default")+"'"
  • bmgriner's avatar
    bmgriner
    Frequent Contributor
    Any response?

    I need this to work. Absolute paths won't work when projects are committed into version control and then checked out by others in different locations.
  • MHolmqvist's avatar
    MHolmqvist
    Occasional Contributor
    But...the auto reload of changed Groovy classes doesn't seem to work when using Project script library?
    I have to restart SoapUI Pro 4.0.1 if I change a Groovy class for the changes to take effect :-/
  • bmgriner's avatar
    bmgriner
    Frequent Contributor
    Thanks for the ideas. It is working for me. I keep forgetting the flexibility of the scripts that can be written in SoapUI. I guess I hope that I will be able to use the UI. The script is not clean for me since I will be committing my absolute path to the scripting library and anyone else who uses it will be committing theirs, but it will replace it as soon as you open up the project. I'll have to check if this will work with the automation of the testing that I am doing through Maven and Bamboo.

    By the way... my scripts seem to reload fine. I went into one of the files in the scripts folder, modified it, and then ran a test that used the new functionality. It worked right away. I am using version 4.0.1 of SoapUI Pro. What version are you using?
  • bmgriner's avatar
    bmgriner
    Frequent Contributor
    Still haven't heard from SmartBear. I can't imagine this would be that big or hard of a change. I guess the main thing I would like to know is if it will be fixed or if it is purposely this way, or if it will not be worked on.
  • I used MHolmqvist's code snippet to load my script library from the project dir, and I ran into the issue of needing to restart soapUI to pick up the changes in the groovy script. However, I notice that if I make any change in my Script Assertion that refers to my external script, any changes I've made in the external script get picked up.

    -make change in external script
    -run assertion: change in external script not recognized
    -add whitespace to assertion
    -run assertion: change in external script recognized

    Still annoying, but less annoying than restarting soapUI.