I had used JMeter to perform tests where the username would change based on the number of times I wanted the test case to be run. I had five test users on my system (user1, user2, user3, user4, user5) and needed to increment the user being used for each call for variability.
Environment:
Jmeter 3.0
java version "1.8.0_66"
Windows 7
Steps:
Set Jmeter user-defined variables to start off with:
Use Jmeter's Bean Shell Pre Processor to set and increment two user-defined variables USER_TO_INCREMENT and INCREMENT_NUM. The script:
- grabs the current value of INCREMENT_NUM, which at the start is 0
- checks if the INCREMENT_NUM value is less than 5, if so will increment the value by 1, else will reset the number to 1
- saves the new USER_TO_INCREMENT and INCREMENT_NUM values to the user-defined variables
Now, for subsequent HTTP calls the USER_TO_INCREMENT and INCREMENT_NUM variables will be used.
No comments:
Post a Comment
I appreciate your time in leaving a comment!