Gatling: Basics of Simulation Script.

Table of contents
Reading Time: 2 minutes

Gatling is a highly capable load/performance testing tool. It hits your API with defined HTTP protocols and generates a beautiful report showing all scenarios with success and failure rate. It is designed for ease of use, maintainability and high performance.

In this blog, I’ll take you through the main components of Gatling Simulation Script. For the basic setup overview of Gatling, you can visit Gatling-Maven-Setup.

In Gatling Simulation Script, the most important component is a setUp() method. It executes the suite of test cases with specified ramped-up users at time boundaries/thresholds. The setUp() needs an HTTP configuration parameter to execute or hit the requested endpoint with given headers like content-type, access-tokens etc.

Given below is an example setUp():

Like you see in the above-given code, the setUp takes a Scenario to execute with some httpConf (i.e HTTP configuration).

With that said, the next component comes into the picture is a Scenario. It is kind of test cases which takes a single Endpoint to hit an up and running API provide its host URL.

A Scenario can also consist of multiple endpoints sequencing them in a chain of execs’ i.e. executions but it is only recommended whenever we have a process dependent scenarios i.e if an endpoint takes the output of another endpoint as input the former can be sequenced after the later in the same Scenario.

The next Component is httpConf:, it is the holder for the header configurations which will propagate with the request hit.

Then there is a Feeder we need many times.

Yeah, so these were some important components of a Gatling Simulation Script we should be aware of. For a running example, please visit Gatling-Sample-Service.

Hope it could help.

Pasted image at 2017_11_27 04_17 PM

Written by 

Yashpal, is a software consultant at Knoldus Inc, having more than 2.5 years of working experience. Yash is familiar with programming languages such as Java and Scala and he is currently working on reactive technologies like Scala, Lagom, Akka, Spark, and Kafka. Yash is also a proactive learner of new technologies and languages. His hobbies include playing chess, Table Tennis and basketball, watching Hollywood movies & series and he also loves listening to good music and singing Indian Vocal.