cancel
Showing results for 
Search instead for 
Did you mean: 

Can't load groovy script from script library

Highlighted
Occasional Contributor

Can't load groovy script from script library

Hi,

I am trying to use the script library feature of SoapUI Pro in version 2.5.1 on Windows. I just can't get it to work. When calling a static method on a class or instantiating a class, I receive a "unable to resolve class" error. When I change the groovy file, SoapUI is reporting and update, "MyTest.groovy is new or has changed, reloading...

But using anything in the file fails.

=== MyTest.groovy
package test

public class MyTest
{
  static def test =
  {
      log.info("Hello Test")
  }
}
===
// Groovy script in Groovy Test Step
test.MyTest.test()

Results in: unable to resolve class test.MyTest @ line 1
3 REPLIES 3
Highlighted

Hi!

is the file in a folder named after its package? (ie "test")

regards!

/Ole
eviware.com


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Occasional Contributor

::) Yes, that works, thanks.

Is it possible to have a collection of groovy functions/closures in a file without a name space (default package name)?

So for example have a file called lib.groovy in the scripts directory with something useful like:

def logInfo = {t -> log.info(t) }
def myFunc() { "This is my function" }
Highlighted

Hi Mark,

script files must be valid classes, not just arbitrary scripts.
So, you can create groovy class with static methods or closures and use them in your script.
And of course if you use default package name put your groovy file into bin/scripts folder.

regards
Nebojsa
eviware.com


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors