How do you insert the same random variable into multiple soapui test request queries?

I can do this completely wrong, but how to transfer a dynamic variable to a bunch of requests within the framework of one test in SoapUI?

My first step of the test is the Groovy script. I need to create an arbitrary account name and then use it in all my other requests. There are 20 more other requests. At first I thought I could just loop testuite, but it does not work.

This is my Groovy script at the beginning:

Random random = new Random()

def randUserAccount = "testAccount" 

int max = 100000
randnum = random.nextInt(max+10000)

randUserAccount += randnum

log.info "     Creating account: $randUserAccount"

Then at each step of the request, I have things like this:

<ns:CreateAccountRequest>
    <accountID>${randUserAccount}</accountID>
...

or

<ns:PurchaseRequest>
    <accountID>${randUserAccount}</accountID>
...

The account is null when I actually send it, and of course this gives server-side errors. How can I get a variable for all requests in testuite?

Thanks in advance for any tips!

+5
2

, . , , .

context.setProperty("randUserAccount", randUserAccount)

, .

, . "" , .

+9

, set, .

jus varaible, .

,

-1

All Articles