How to define a global class in SoapUI as a groovy script?

Viewed 9175

I want to define a class in a groovy script that i could reuse trough other groovy script inside SoapUI.

I alredy tried to define my class inside a TestSuite property but it doesn't work. I would like to avoid defining the class in a JAR because we work in team and every one would have to import the JAR in their SoapUI in order to run my tests. I use SoapUI 3.6.1

Here's how my TestSuite is made :

TestSuite
  TestCase
    TestSteps
       Init         (Groovy Script)
       GetResponse1 (Test Request)
       Test1        (Groovy Script)
       GetResponse2 (Test Request)
       Test2        (Groovy Script)

To simplify me tests, i defined a class in 'Test1' and i would like to reuse this class in 'Test2'. So ideally i would define that class in 'Init' and it would be accessible to any other groovy script.

How can i achieve that?

5 Answers

In SoapUI 5.3.0 you can use properties that can be set and get on the context variable. That variable is available in script assertion snippet.

For example: context.setProperty("prop", "value");

And from different test script you can get the value by: context.getProperty("prop");

You can use the property from when you define property as a step of test suite or as a value for field in header. You can do it by ${=context.getProperty("prop");}

Related