0
votes

I have the following code construct in Jmeter:

Test Plan
- CSV Data config (reading in test reacords)
- Execution Thread
- - Do While (contains condition Counter < 5)
- - - Counter element (set to start at 1, increment by 1)
- - - Http request sending test record to api

The problem I am getting is that the Counter is not resetting after each test record is sent through, so the first record through works fine (5 iterations), the second stops at the first iteration.

I've tried: 1) Set counter in User defined variables 2) Reset counter element using a beanshell (this didn't work at all)

My test uses a single thread group with a single user thread. Each record in my csv file is only run through the system once.

How do I successfully reset the counter for each record?

1
Did you set "Reset counter on each Thread Group Iteration" checkbox? If that's not doing what you want, please provide more detailsKiril S.

1 Answers

1
votes
  1. If your "iterations" come from the Thread Group just do this:

    JMeter Counter Reset

  2. If your "iterations" are not driven by Thread Group and come from i.e. Loop Controller you can reset the counter by the following Groovy script:

    vars.put('Counter', '1')
    

    You can use the above script in any of JSR223 Test Elements or in __groovy() function available since JMeter 3.1. In the latter case you will need to escape the comma like:

    ${__groovy(vars.put('Counter'\, '1'),)}