By the end of this post you will be able to add a Loop
Controller and Counter to your script which will loop a request n no of times.
Note: If the counter exceeds the maximum, then it is reset to the Start value. If your loop count is 10 and maximum value is 5, then you will get output 1,2,3,4,5,1,2,3,4,5
Loop Controller
Loop Controller is a Logic Controller which determines the order in which Samplers are processed.You can use Loop Controller, if you want to loop a request/logic a certain number of times in addition to the loop value specified for the Thread Group.
Counter
Counter can be used anywhere in the Thread Group. User can set a start point, maximum value of counter and the increment using counter config.Counter will start from start point and reach the maximum value and then reset back to the start value, it will continue like that until the test is ended.
Add Components:
Loop Controller is a Logic Controller which determines the order in which Samplers are processed.You can use Loop Controller, if you want to loop a request/logic a certain number of times in addition to the loop value specified for the Thread Group.
Counter
Counter can be used anywhere in the Thread Group. User can set a start point, maximum value of counter and the increment using counter config.Counter will start from start point and reach the maximum value and then reset back to the start value, it will continue like that until the test is ended.
Example:
We will loop a request 10 times using Loop Controller. And we will set Counter values start with 1, Increment by 1 and reach Maximum 10.
So JMeter will send 10 request with counter values 1 to 10 as shown below in results.
Please follow below steps to add loop Controller and counter.
- Add Loop Controller to Thread GroupRight click on Thread Group > Add > Logic Controller > add Loop Controller.
- Add Counter to Loop Controller
Right click on Loop Controller > Add > Config Element > add Counter - Add HTTP Request Sampler to Loop
Controller
Right click on Thread Group > Add > Sampler > HTTP Request - Add View Results Tree to Thread Group
Right click on Thread Group > Add > Listener > add View Results Tree
Loop Controller:
Using Loop Controller, JMeter will loop through a certain
number of times, in addition to the loop value you specified for the Thread
Group.
Set Loop counters
value to 10
Counter:
The counter configuration lets the user configure a starting
point, a maximum, and the increment. The counter will loop from the start to
the max, and then start over with the start, continuing on like that until the
test is ended.
Set Values:
Set Values:
Start: 1, Increment: 1, Maximum: 10, Format: 00, Reference
Name: Count
Note: If the counter exceeds the maximum, then it is reset to the Start value. If your loop count is 10 and maximum value is 5, then you will get output 1,2,3,4,5,1,2,3,4,5
HTTP Request Sampler:
Change request name to say: Counter value - ${Count}
Set Server Name: google.com
Save and Run Script:
Save the above script and Select "View Results Tree" and click on
"Start"
Results:
No comments:
Post a Comment