ReadyAPI 1.4.1 Inline Command is always executed
Hi
In Soapui I used to use this approach to create random user names. But it is not working as expected inside READY API.
Inside a SOAP request I have something like this:
<userName>User_${=(int)(Math.random()*1000)+9999}</userName>
That will generate one random name every time this request is called.
Example:
<userName>User_5555</userName>
This is fine but when I'm trying to read this generated name from another Step on the same test case one new number will be generated.
I'm using this command to read this user name from the RawRequest:
${setNewUser#RawRequest#//userName}
And that random command will be executed again, generating a new user name every time I try to read the username generated on that other Test Step.
Unfortunately it was working on SOAPUI 5.2.0 but it is not working on READY API
WorkAround:
I don’t want to change all projects I have but I know it’s possible to use this workaround to avoid this Issue. Write an Groovy script to generate this random name and storing it on a TestCase custom property.
Hi Chimas,
Our R&D team has found out that SoapUI and Ready! API work in the same way – a new value is generated each time they got access to userName.
If the behavior is different in your case, could you please provide us with a sample project that demonstrates the differences between the products results?
Jparel, I was informed that this behavior is related to the Groovy library update (2.1.7 for 5.1.2 and 2.4.4 for 1.5.0). Our team suggests that you update your groovy code to this:
(int)(Math.random()*99999) + 10001
Brackets must be around the code:
Math.random()*99999
Since Math.random() returns the pseudo random value from 0 till 1, when it casts to int it becomes 0! Therefore, you get 10001 every time.