Search code examples
while-loopjmeter

Jmeter while condition - adding multiple condition is not working as expected


Iam in a situation that i need to check 4 conditions in a loop, as soon as condition matches loop will exit, if not matched then i need to run for <=9 attempts. below is the condition i have used. below condition is working fine in case if 4 condition results are matched, in case if any one condtion is failed jmeter is running in a infinite loop.

${jexl3("${compilerstatus}" != "Compilation Successful." && "${compilerstatus2}" != "Compilation Successful." && "${compilerstatus3}" != "Compilation Successful." && "${compilerstatus4}" != "Compilation Successful.")} || ${jexl3("${counter_value}" <= "9")}

enter image description here


Solution

  • If your problem is that the loop doesn't break after 9th iteration it's due to comparing 2 Strings using <= operator, you should remove quotation marks so it would be Integers.

    I think you need to change this line:

    || ${jexl3("${counter_value}" <= "9")
    

    to this one:

    || ${counter_value} <= 9)
    

    Something like:

    ${__jexl3("${compilerstatus}" != "Compilation Successful." && "${compilerstatus2}" != "Compilation Successful." && "${compilerstatus3}" != "Compilation Successful." && "${compilerstatus4}" != "Compilation Successful." && ${__jm__While Controller__idx} <= 9,)}
    

    More information: