1. Add Config Element > User Defined variable under Test Plan
2. Add 2 variables like i) Name = counter & Value = 0 ii) Name = test
3. Add loop counter under Thread
4. Add BeanShell preprocessor
5. Add following code in BeanShell preprocessor
String s = "Data";
//Read value of user-defined variable "counter" > convert to int > increment by 1.
int counter = Integer.parseInt(vars.get("counter")) + 1;
//convert counter to string and change value of user-defined variable.
vars.put("counter",Integer.toString(counter));
//Change value of user-defined variable "test"
vars.put("test",s.concat(Integer.toString(counter)));
Note: Use user-defined variable "test" in HTTP request sampler as ${test}
2. Add 2 variables like i) Name = counter & Value = 0 ii) Name = test
3. Add loop counter under Thread
4. Add BeanShell preprocessor
5. Add following code in BeanShell preprocessor
String s = "Data";
//Read value of user-defined variable "counter" > convert to int > increment by 1.
int counter = Integer.parseInt(vars.get("counter")) + 1;
//convert counter to string and change value of user-defined variable.
vars.put("counter",Integer.toString(counter));
//Change value of user-defined variable "test"
vars.put("test",s.concat(Integer.toString(counter)));
Note: Use user-defined variable "test" in HTTP request sampler as ${test}
No comments:
Post a Comment