Starting with Gatling using Maven

Reading Time: 4 minutes

Gatling is an open source load testing application, which uses Scala scripting language. Unlike Apache JMeter, Gatling doesn’t have a GUI interface. So, when you want to simulate a given scenario, you do it by writing a Scala script.

Here we will learn how to write Gatling script using Maven and also, understand the basic architecture of the script by using test scenario.


  • Maven should be downloaded and path should be set on the env variable.
  • Scala Plugin should be installed and integrated with IDE.

To setup Maven we have to follow below step:

  1. Click on New Project (File >> New Project)
  2. Select Maven ,Check on create from archetype and click on Add archetype option
  1. Enter GroupId, ArtifactId and Version on prompted window (you can find these detail in the link , Now click on Ok and Next
  1. Now give user friendly Name and ArtifactId and GroupId and click on Next and Finish.
  • groupId – by this Id your project will be uniquely identify across all the projects. Ex- com.gatling-practice
  • artifactId – this will be unique name of the project.
  1. Now Setup sdk for that Open Engine file (src >> scala >> Engine.scala) and click on Setup sdk

6. The pom.xml will create automatically and looks like :

  1. Now Create a simulations folder under scala folder and add scala file.p

Now you are good to start writing your script 

Simulation Architecture:

Gatling script consist of four section :

  • The HTTP protocol configuration
  • The headers definition  
  • The scenario definition
  • The simulation definition

HTTP protocol configuration

In this section we will provide information about our request for

  • baseUrl 
  • Common Headers, which will be added on each request

The HTTP Configuration is stored as a Scala value so that we can set it later in the simulation definition.

Headers definition

This section comes in picture when we have to define separate headers for each scenario. If we have common headers for all the scenarios then we usually do not use this section in our script.

Scenario definition

In this section we can define according to the requirement/use cases by providing a user friendly name and we can define several scenarios in a single script.

Scenario use two methods: exec and pause

  • The exec method is used to execute an action. Actions are usually requests that will be sent during the simulation
  • The pause method is used to simulate the think time of the user between consecutive requests.

Simulation definition

Here we are defining simulation like how many user can put the load on the server with the help of setup we can inject load in server by passing users in atOnceUsers method.

Configuring the Gatling Script:

Below Script code snippet is in Scala Programming Language

Script Execution:

We can execute script by two way:

  1. Through IDE – (Right click on Engine and click on Run “Engine”)
  1. Second way to execute script is through maven command from Terminal,

To execute command from terminal first you need to navigate to the Project directory after that run below command

mvn gatling:test

Note– to execute script using test field this you need to provide test(or any user friendly name) in scope tag of POM.xml. Kindly refer the screenshot present in step 6.

Gatling Report:

To view report either copy and paste the report path on browser which is appearing on the terminal or you can navigate to the project directory inside directory you will find these folder >>target>>gatling>>demoscript there you will find index.html click on that

Reference link:

For more blogs please visit to site