Scenarios

Learn how to use scenarios in the Gatling script.

We'll cover the following

In the previous lesson, we learned about the features offered by Gatling. In this lesson, we will learn about scenarios.

What is Scenario?

Scenario represents the actions performed by a user.

The exec method in a scenario is used to execute an action, which can be any of the following request types:

  • http – execute a HTTP call.
  • ws – execute a Web Socket call.
  • jms – make a Java Messaging Service request.
  • sse – make a Server Side Event request.
  • mqtt – make a Message Queuing Telemetry Transport request. This option is applicable only to the commercial version of Gatling, Frontline.
  • inject or manipulate data in the user session.

Each of the building blocks has its own construct for making the request.

A simulation file can have multiple scenarios, and each scenario needs to have a unique name.

Sample simulation

In the below sample simulation, we have a scenario that executes an HTTP call and a Web Socket call in a sequence. We can have a mix of all the possible building blocks.

Get hands-on with 1200+ tech skills courses.