Ask a Question

New script result when called


New script result when called

I have a groovy script that generates a random iban. I want to be able to get the result from this script in a lot of teststeps.


I now have this script in a Scripts suite and use it by inserting this in my request ${#[Scripts#Random IBAN#Random IBAN]#result}. This will always return the same result(iban).


How can I make the script generate a new iban when called from other tests without inserting hundreds of "Run TestCase" steps before every request that uses an iban?

Super Contributor

The script generates the result when the step executes so the result is always the same when you reference this.


Personally, I use the DataGen test step (instead of your Groovy Test Step), with a script property, if you set the mode to "READ" the property is recreated each time it is read.


Important Caveat: The DataGen test step script property has been deprecated in favour of the Groovy Data Source data source of the DataSource test step. But I just like the sheer simplicity of the DataGen test step (and its what I've always used).


For completeness, If your Groovy test step is a standalone function you could also move your Groovy code to an external Script Library.


SoapUI supports in-line groovy scripts, so depending on the complexity of your script you could do something similar to:


${= insert groovy code here }

The problem here is that you will then have to maintain the groovy script across any/all test steps that contain that which can get unwieldy very quickly. If you use the Data Gen recommended step, that may be a short term solution since, as @Radford mentioned, it has been depricated.


Setting it as being in the external script library would mean you only have to maintain it in one place, so if that code ever has to change it'd be much easier to maintain. 


Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Showing results for 
Search instead for 
Did you mean: