0

I have a bunch of HTTP Requests inside my Threads group and I want all of them to be evaluated inside an IF Controller which has a specific condition.

enter image description here

JRS233 Listener contains this script:

if (!prev.isSuccessful()) {
    vars.put('samplerFailed', 'true')
}

if(prev.isSuccessful()) {
    vars.put('samplerSuccess', 'true'); 
}

if CONTROLLER OK cointains this condition:

${samplerFailed}

and if Controller KO has this condition:

${samplerSuccess}

I want the two IF CONTROLLERS to be executed for all the samplers.

How can I achieve it?

thanks

eeadev
  • 3,662
  • 8
  • 47
  • 100

2 Answers2

1
  1. Add JSR223 Listener to your Test Plan (the same level as all the HTTP Request) and put the following code into "Script" area:

    if (!prev.isSuccessful()) {
        vars.put('samplerFailed', 'true')
    }
    
  2. Change your If Controller condition to ${samplerFailed}

This way If Controller's children will be executed only if there is any failure in the samplers in scope of the JSR223 Listener.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
0

You can loop through different URLs/ HTTP Requests and do same logic for each request.

Put HTTP request and If Controllers under While Controller and add CSV Data Set Config that will read your URLs from a file.

While loop will stop until finish reading CSV file using ${url} condition

your flow will remain the same, the only different it will be executed per line in CSV file.

Ori Marko
  • 56,308
  • 23
  • 131
  • 233