Forum Discussion

blackchoc's avatar
17 years ago

Scripts per Project

Hello,

I use the Groovy Script Features of SoapUI extensivly. I have read all forum
posts about this topic, so I will try to explain the requirements in a certain test environment. Lets say you have a directory structure like this one:

TestTopic01
  scripts
  testdata

  Test01
      testdata
  Test02
      testdata
      scripts

TestTopic02
  scripts
  testdata

  Test01
      testdata
  Test02
      testdata 
      scripts
...

Every TestTopic is one SoapUI project. Every SoapUI project is probably
used/worked on by a person at any time. But you always have at least
two projects open in SoapUI.

You could fake "local" scriptfolder by dumping everything into a large
top folder with packages "TestTopic01" and so on. This would be usable,
if it  wouldn't require constant changing of the relevant "Topic" subfolder
in the global properties, since you swap often between projects.

But it doesn't solve the problem, that you might need additional, testSuite
specific helper functions, which SHOULD reside in the "subfolder" of the
testSuite. Currently, I use following SetupScript in any project to change the script folder:


def scriptDirectory = context.get('${projectDir}')+"\\scripts"
com.eviware.soapui.SoapUI.settings.setString( "Script Library", scriptDirectory)


This alone doesn't the trick, because if you don't change the timestamps of
files, nothing happens. You have to add (simplified pseudocode)


      for (anyfile in scriptdir incl. subdirs) anyfile.touch()


This wakes up the script-reloader, and then you go. But I find this cumbersome
and error prone. It also requires that the tester/coder runs all tests from the top
and not just the one testSuite he is interrested in. It also makes moving of
testSuites difficult, because you have to rememeber to move specific scripts from
the top folder...you see the point.

I also can't write a EventListener, because this would require a (currently
nonexisting) "ProjectActive" or "ProjectActivated"-Event which reacts on every
project "activation" (or "focus" if you will).

In earlier versions (I think, Pro 2.5.1?), it worked (sometimes) to set the global
script library to something like "${projectDir}\scripts". But this was probably
more a side-effect than a supported feature 

The best solution would be, if it where possible to set special properties
in project, testsuite, testcase like "scriptlibrary.localscriptdir" As soon you
"activate" a project, the scriptloader scans trough all properties and reloades
all scripts found on all levels. (I guess some caching would be useful performancewise).

For a first quick hack, it would be enough to have a "projectActivated" event,
I could do the rest for now

As a sidenote: it would be helpful if there where another way to force
reloading the scripts, something like "ClasspathHacker.purgeScripts()"
instead of cheating timestamps 

thank you for listening
-Igor

14 Replies

  • skillsoft's avatar
    skillsoft
    Frequent Contributor
    Hi,

    I installed last night's nightly build and although I can set the Script Library property under Project Properties on the bottom left, it doesn't seem to do anything. I've tried both with leaving the File\Preferences\soapUI Pro\Script Library field blank and populating it with a value. I've noticed that when you leave it blank it defaults the script library to <soapui install dir>\bin\scripts (SoapUI Log says this) upon restart.

    In both cases, it seems to take what is set in File\Preferences\soapUI Pro\Script Library if it is populated or <soapui install dir>\bin\scripts if it is blank, it ignores what is set for script library under the Project Properties.

    One other comment, and maybe this is as designed but changing the value of File\Preferences\soapUI Pro\Script Library always requires a restart before it takes affect. It's worked this way since I've used script library in 3.0.1 so it's nothing to do with the fix you put in. Is this as designed or is this an bug?

    Thanks,

    Mary
  • skillsoft's avatar
    skillsoft
    Frequent Contributor
    Hi,

    Do you think you might fix the Scripts per project functionality with a nightly build or should I enter an enhancement request and hope it gets added in a future release?

    Thanks,

    Mary
  • skillsoft's avatar
    skillsoft
    Frequent Contributor
    Are you guys on vacation or are you away at a conference? You haven't answered much of anything on the boards lately.

    Thanks,

    Mary
  • Sorry about not getting back to you, we have been a bit busy with the release of loadUI, as well as with forum problems.

    I do think you should add that as an enhancement request, and we will add it to a future release.