Exit entire simulation on condition / error


We’ve got a simulation comprised of multiple sequential scenarios. The first one will optionally perform some data setup and I’d like to be able to terminate the entire simulation based on certain conditions at the end of this first scenario. Exiting if this first scenario errors would also be acceptable.

At the moment if I cause that first scenario to fail and use something like exitHereIfFailed I see the error is produced, but the subsequent scenarios continue as normal. Is there a recommended way of performing this kind of setup?



I couldn’t find a proper workaround so I added a new DSL component to be available in 3.7, see https://github.com/gatling/gatling/issues/4162


Hi Stéphane,

Thanks for the quick solution, I’ll try building that locally to see how it works.

Do you have any idea on when 3.7 will be available?


Gatling 3.7 will be out tomorrow.
Gatling Enterprise and Cloud releases supporting Gatling 3.7 will follow in the next few days, probably on Wednesday and Thursday respectively.

That’s great, thanks!

Hi Stéphane,

I’ve just tried this out this morning and I’m still having trouble. Perhaps the way we’re constructing the scenarios won’t work with this new method? Are we doing something wrong?

Here’s a gist where I’ve provided a skeleton of how the simulation fits together. The first two steps are where we perform checks that I’d like to use to exit the simulation completely if the checks don’t pass or if an error is produced.



Please provide a full working example.

Sure, here’s a complete example. I’m hoping to prevent the main scenario from running by making either of the previous two steps fail



.stopInjector(“Error during database population”)

With the exitHereIfFailed , you’re telling the user to exit its scenario so it never reaches stopInjector

Okay sure, that makes sense. I guess I’m not sure how best to use stop injector then?

If I build a scenario with the stop injector included then it will always stop the simulation. How can I only invoke stop in certain conditions (e.g. an error is raised)?

Thanks for your help

In a doIf block? eg

doIf(_.isFailed) {

Oh of course, thanks Stéphane!

Hi - this appears to be working great locally now. Thanks for all your help.

Do we need to upgrade anything else in order to use 3.7? We’re seeing this message when running from frontline

Failed to validate packages: Simulation was compiled with an incompatible Gatling version: 3.7.1. Please upgrade to 3.5. Terminating instances.

We’re about to release Gatling Enterprise 1.16.0 that will support Gatling 3.7.
You’ll have to upgrade.