Royce
Royce

Reputation: 1595

Iterate over csv file with While Controller

I try to iterate on a .csv file with a While Controller. I want only one iteration.

The condition used for stop the loop is the follwing one : ${__javaScript(vars.get("TestCaseName") != "")}

Thread Group config

CSV Data Set Config

However, an infine loop is generated...

Can you help me please?

Thank you !

Upvotes: 0

Views: 1292

Answers (1)

Dmitri T
Dmitri T

Reputation: 168162

  1. Put your CSV Data Set Config inside the While Controller
  2. Amend the While Controller's condition to use:

    • __groovy() function as since JMeter 3.1 you should be using Groovy for scripting
    • __jm__While Controller__idx variable to stop after the first While Controller's loop

      ${__groovy(!vars.get("TestCaseName").equals("") && (vars.get("__jm__While Controller__idx") as int) < 1 ,)}
      

    enter image description here

Check out Using the While Controller in JMeter for more hints if needed

Upvotes: 1

Related Questions