Mats Johansson
Mats Johansson

Reputation: 87

JMeter - if controllers on thread group

Is it anyway I can have an if controller above a thread group, like:

TestPlan -> If controller ----> Thread Group

I.e I just want to execute the if controller once so I can avoid unnecessary execution in the Thread Group?

Upvotes: 2

Views: 857

Answers (2)

Dmitri T
Dmitri T

Reputation: 168197

There are following options:

  1. Put everything inside the Thread Group under the If Controller, this way no Samplers will be executed if the condition is not met, but the Thread Group will be still started and all threads will kick off
  2. Set number of threads in the Thread Group to 0, it can be done using __if() function (member of JMeter Custom Functions plugin bundle, can be installed using JMeter Plugins Manager)
  3. You can also consider running your JMeter test using Taurus tool as the wrapper, Taurus provides possibility to completely disable arbitrary test element (including thread groups) using simple declarative YAML syntax

Upvotes: 1

Ori Marko
Ori Marko

Reputation: 58882

You can add to Thread group in Number of Threads field get value from property, as:

${__P(GroupANumberOfThreads,0)}

So if you don't have property, for example don't send -JGroupANumberOfThreads=1 in CLI mode Thread group won't get executed

Upvotes: 2

Related Questions