Monday, July 23, 2012

SOAPUI, setting dynamic properties with Groovy

I have a project POCO
and a Test Suite with a TestCase POCOTest

In the TestCase I create a Groovy Script step:

def project = context.testCase.testSuite.project
def tc = context.testCase

see also:

Now, if I want to set a property, I have a choice of TestCase, TestSuite, Project or Global properties.

For instance, to set a new OrderID per each request:

import static java.util.UUID.randomUUID
def tc = context.testCase
uuid = randomUUID().toString()
testRunner.testCase.setPropertyValue( "OrderID", uuid ) testRunner.testCase.getPropertyValue("OrderID")

After execution of this code (click the Run button in the Groovy Step editir), you have:

now you can add other steps AFTER the Groovy Step, and in the XML requests you can put


All the Steps will share the same value of OrderID.

No comments: