I have searched both here and via google trying to find the best way to generate random numbers in test cases. I have attempted to work with strings such as the below:
Solved! Go to Solution.
Random number between the range
Math.abs(new Random().nextInt() % max + min)
So, in your case - Math.abs(new Random().nextInt() % 17 + 3)
You may have goovy script
context.testCase.testSuite.project.setPropertyValue("ACCOUNT_NUMBER", (Math.abs(new Random().nextInt() % 17 + 3).toString())
And you need to use ${#Project#ACCOUNT_NUMBER} where that is needed.
Just thinking of the number to tests to make the changes like you mentioned, you may alternatively look at Events - FilterRequest to modify the request with the changes need to avoid bulk changes for each test case if possible. Currently can't say much as do not know about the data variations.
Random number between the range
Math.abs(new Random().nextInt() % max + min)
So, in your case - Math.abs(new Random().nextInt() % 17 + 3)
You may have goovy script
context.testCase.testSuite.project.setPropertyValue("ACCOUNT_NUMBER", (Math.abs(new Random().nextInt() % 17 + 3).toString())
And you need to use ${#Project#ACCOUNT_NUMBER} where that is needed.
Just thinking of the number to tests to make the changes like you mentioned, you may alternatively look at Events - FilterRequest to modify the request with the changes need to avoid bulk changes for each test case if possible. Currently can't say much as do not know about the data variations.
Many thanks Rao, you gave me just what I was looking for!
Subject | Author | Latest Post |
---|---|---|