cancel
Showing results for 
Search instead for 
Did you mean: 

loadUI not running testCase in sequence

sharjeel
New Contributor

loadUI not running testCase in sequence

I have a REST API based testCase. Within the testCase, i am using Setup Script (groovy) to increment a property called 'id' s value by 1. The test steps within the test case use this id in their json request. This id has to be unique for each test case.  The issue is when I run this test case using loadUI with 2 VU (Virtual Users), loadUI starts two test cases with the same 'id'. I have to keep the 'id' as unique for the test steps within the test case to work. Please advise.  

2 REPLIES 2
Lucian
Community Hero

Re: loadUI not running testCase in sequence

Instead of incrementing the id you can generate a random id each time. So it won't matter how many VUs you have. For instance the next script generates a random number between 1 and 10000:

 

log.info ( Math.abs(new Random().nextInt() % 10000) + 1 )


If my answer helped please click on the 'Accept as Solution' button.
msiadak
Community Hero

Re: loadUI not running testCase in sequence

Maybe you can look at using a groovy script data source that can house the ID property and increment appropriately? Or using the set-up groovy script to populate a grid datasource that is shared among the VU's in the load test. That might help solve this problem. I've done similar in the past when I needed unique data during a load test.




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
New Here?
Join us and watch the welcome video:
Announcements