soapUI: Re-use of a Property with random value

In a test suite I wanted to use a Random value for a soap request, so I defined a Property that is initialized with a random value (see also my previous post on soapui).
The next thing that I wanted to do is to use that same Property to check whether an item was correctly inserted into a database. So for example:
Name: empid  Value: ${=(int)(Math.random()*100000000)}

step1: soap request    

step2: JDBC request 
select * from Employees where
   empid = '${#TestCase#empid}'

To my surprise this construction did not work!
In fact in the second step the empid property was given a new random number !!

I tried several other options, like:
  • Define properties on other level (TestSuite, TestCase, Project)
  • Use a second Property and transfer the first random Property to the second. In this case the transfer is just a transfer of the Groovy script !!??
In the end I got the following solution:
  • Double click on the TestCase
  • Define a Property empid with value 0 (for example, it does not matter) (On the Properties tab)
  • On the Setup Script tab initialize the Property:
  •  Now you can use this Property with random value and that is initialized only once !
Hope this blog item helps you in using the tool, just the way you want :-)


  1. Thanks for sharing this useful information...

  2. thanks for sharing this.

  3. Thanks a lot,

    It took me hours to find out how it works.

  4. Thank you, it works fine. I copy here the text so that other people can just copy-paste it instead :

    testCase.setPropertyValue("empid", String.valueOf((int)(Math.random()*100000000)));

  5. A big THANK YOU for this great tip.

  6. hi,we provide online training & video tutorial for soapui
    for free videos refer