Search code examples
jmeterperformance-testing

if controller for OR Condition in jmeter


I am working on a scenario where we need to do an action when status is either FAILED or DID_NOT_START, below are the mention status

"status": "DID_NOT_START", "status": "FAILED", "status": "STARTED", "status": "IN_PROGRES", "status": "SUCCEEDED",

we used regular expression extractor for correlation with match no as 0(Zero for random variable need to be picked), regular expression extractor plugin

i used below mentioned statements but not worked, please help

"${status}" == "FAILED" || "${status}" == "DID_NOT_START"
"${status}" == "FAILED" | "${status}" == "DID_NOT_START"
"${status}" == "FAILED" && "${status}" == "DID_NOT_START"

Ifcontroller

we need to do execute particular transaction when status is either FAILED or DID_NOT_START, please help


Solution

  • The correct statement is "${status}" == "FAILED" || "${status}" == "DID_NOT_START" however you cannot use it in the If Controller per se.

    If Controller executes its children if the Function or Variable used in the condition input evaluates to true

    So you need to wrap the statement into i.e. __jexl3() function and it will "work"

    ${__jexl3("${status}" == "FAILED" || "${status}" == "DID_NOT_START",)}
    

    enter image description here

    If it still "not worked" use Debug Sampler to ensure that your status variable exists and has the anticipated value