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.