Reputation: 143
I need to register with multiple user for load testing in my application and for this 'CSV Data Set Config' is the simplest solution but for this I need to update unique value (e.g email) each time in csv file I run the load. Is there a way in Jmeter so that I mention like [email protected] (where X is variable) and setting a counter to X which will give me multiple values
Upvotes: 1
Views: 626
Reputation: 21
The problem with the above solutions is that the counter would need to be set to start at a new value every time you run the script as your users will already be registered. I construct my emails using __time to give me unique values as shown below:-
"email": "joebloggs+${__time(yyyyMMddhhmmssSSS)}@gmail.com",
Upvotes: 0
Reputation: 288
Add a counter (Add > Config Element > Counter) to the http request before the request that needs the unique email address. Be sure to leave the "Track counter independently for each user" box unselected. For the scope of this answer we'll say the Reference Name of the counter is "myCounter" and the variable for the username from the csv dataset is "userName".
Add a preprocessor to the http request that requires the email address. Here add the following code:
String myCounter = vars.get("myCounter")
String user = vars.get("userName")
String email = user+myCounter+"@gmail.com"
vars.put("email", email)
Call the email address in your request as such:
${email}
Alternatively, if you only need the number to be different you can do this:
String myCounter = vars.get("myCounter")
String email = "kumarnipun"+myCounter+"@gmail.com"
vars.put("email", email)
Upvotes: 1