How do you insert the same random variable into multiple soapui testcase requests?

I may be going about this in the completely wrong way, but how do I pass a dynamic variable to a bunch of requests within the same testsuite in SoapUI?

My first test step is a Groovy script. I need to generate a random account name, and then use it in all my other requests. There are about 20 other requests. I initially thought I could just loop the testsuite, but it is not working.

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 in each request step, 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 that gives errors on the server side. How do I really get the variable to persist across all the requests in the testsuite?

Thanks in advance for any hints!

Answers


You can use the context, I believe. You can definitely use it between requests in a test, but I also think it will work between tests in a suite.

context.setProperty("randUserAccount", randUserAccount)

Then use the syntax you specified in the actual requests.

Let me know if this doesn't work. You can also use 'properties' to do this, but it is a little more work.


Need Your Help

'Exec' parameter with 'echo' and 'awk' filter

shell awk exec echo ksh

There's this line I want to use in a ksh script :

How to remap the Ctrl+Click “Go To Definition” short-key in the Productivity Power Tools (or maybe ReSharper)

visual-studio-2010 visual-studio resharper productivity-power-tools

I love the Productivity Power Tools extension for visual studio, however it has added the Ctrl+Click "Go To Definition" functionality, which is great and all, but my workflow makes me use the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.