JMeter annoyances with If Controller – missing ; before statement

After repeated issues trying to get what I thought would be a simple ‘If controller’ working in JMeter, it looks like my issue is to do with the poor examples on the JMeter site. Or else something is making my version and or/installation behave differently.

While the example provided on the JMeter site would have led me to use “${valid_data}”==”Y” as the Condition, with the ‘Interpret Condition as Variable Expression’ field unchecked, doing so was causing a silent failure.

After checking the log files, I could see this error:

“jmeter.control.IfController: missing ; before statement ”

After following some diagnostic advice that failed to work (the log function just seemed to repeatedly spit out my condition as a string, not evaluate it), and randomly experimenting with combinations, I still hadn’t managed to make it work as the log function was also seemingly not passing back the return value. So I removed it and then discovered that I’d somehow managed to make it work. The solution was to add a semicolon at the end:

“${valid_data}”==”Y”;

That was all it took. All good. Hope this helps someone.

4 comments on “JMeter annoyances with If Controller – missing ; before statement”

  1. Matt says:

    I also had an issue with the IF Controller silently failing. My issue turned out to be that the IF Controller and it’s child were ignored if the only enabled child is a timer. I added a dummy sampler to the controller, and it started working.

  2. Dennis says:

    I found to perform a conditional test on a user parameter, I also had to switch from using == to the equals() function.

    With all checkboxes disabled and user parameter queryJson set to yes, the following will execute.

    “${queryJson}”.equals(“yes”);

  3. Matt Joste says:

    I tried every syntax and several different JMeter variables and properties, but the IF Controller would not work.

    As Matt above noted, it started working when I added a dummy sampler(Debug Sampler).

    This was pretty frustrating

  4. Matt Joste says:

    For the IF Controller issue, I added a bug to the db here:

    https://bz.apache.org/bugzilla/show_bug.cgi?id=60245

    Bug 60245 – If Controller: Need to Add Sampler Child for logic to work

Leave a Reply

Your email address will not be published. Required fields are marked *