Forum Discussion

sharjeel's avatar
sharjeel
New Contributor
7 years ago

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.  

  • groovyguy's avatar
    groovyguy
    Community Hero

    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.

  • Lucian's avatar
    Lucian
    Community Hero

    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 )