The Gatling bundle is a self-contained project that lets you quickly start load testing. The bundle avoids manual configuration by including all the files and dependencies needed to run Gatling. Some benefits of the bundle are:
For larger projects or deeper integration into the development process, the Gatling bundle becomes limited. In particular, integrating load tests into CI/CD pipelines is much easier with a build tool. If you have reached this point in your load testing, Gatling recommends migrating to a dependency management tool like Gradle for:
This guide details migrating Gatling tests to Gradle in 5 minutes or less.
Before starting the migration process, it is useful to review the Gatling bundle file structure. The bundle contains the components required to run Gatling and has several key directories.bin: This directory stores the Gatling and the Recorder start scripts.
conf: Housing the Gatling, Akka, and Logback configuration files; this directory is for the technical configuration of Gatling. You can configure the parameters of your tests and monitor the generated logs.
lib: This directory contains Gatling and its dependencies.
results: Stores your Gatling test results.
user-files: This directory centralizes your simulation scenarios. The simulations subfolder will receive the code for your Gatling tests. The resources subfolder hosts files other than the source code, such as feeder and templates for request bodies. You can also add dependencies in the lib subfolder.
We recommend an IDE like IntelliJ for composing and managing load tests to benefit fully from Gradle’s functionality. To directly import the plugin demo with IntelliJ:
Go to File > New > Project from Version Control
You can identify the Gatling bundle version by the file name gatling-charts-highcharts-3.x.x.jar., where the 3.x.x indicates the version. For example, the current version is 3.9.5. The best practice is to have the same version in your Gradle project configuration and the bundle for a successful migration.
The demo projects on GitHub use the latest version of Gatling. If your version is older and you prefer to keep the existing one, you can adjust the version in your Gradle project configuration.
Element | Location in the Bundle | Location in Gradle | Mandatory |
Test Case | user-files/simulations/* | src/gatling/java/ | Yes |
Resources | user-files/resources/* | src/gatling/resources/ | Yes |
Gatling configuration | conf/gatling.conf | src/gatling/resources/gatling.conf | No |
Logback configuration | conf/logback.xml | src/gatling/resources/logback-test.xml | No |
Recorder configuration | conf/recorder.conf | src/gatling/resources/recorder.conf | No |
To configure a specific version of Gatling, modify the build.gradle file.
plugins {
id 'java'
// The following line allows to load io.gatling.gradle plugin and directly apply it
id 'io.gatling.gradle' version '3.9.5.5'
}
Element | Location in the Bundle | Location in Gradle | Mandatory |
Test Case | user-files/simulations/* | src/gatling/scala/ | Yes |
Resources | user-files/resources/* | src/gatling/resources/ | Yes |
Gatling configuration | conf/gatling.conf | src/gatling/resources/gatling.conf | No |
Logback configuration | conf/logback.xml | src/gatling/resources/logback-test.xml | No |
Recorder configuration | conf/recorder.conf | src/gatling/resources/recorder.conf | No |
To configure a specific version of Gatling, modify the build.gradle file.
plugins {
id 'scala'
// The following line allows to load io.gatling.gradle plugin and directly apply it
id 'io.gatling.gradle' version '3.9.5.5'
}
Once you have completed migrating files from the Gatling bundle to your Gradle project, you should validate the migration. You can use the Gradle wrapper or locally install Gradle to validate the migration.
The Gradle wrapper, built by Gatling, provides sufficient flexibility to run your load tests for most projects. Use the built-in wrapper by running the following command in the root directory of your Gradle project.
#Linux and Mac OS
./gradlew gatlingRun
#Windows
gradlew.bat gatlingRun
Some reasons you might not want to use the wrapper include corporate network restrictions or the need for more granular settings. For these cases, installing Gradle is preferable. See the official Gradle website for installation instructions.
Run your Gatling test with a local Gradle installation with the following command in the root directory of your project.
gradle gatlingRun
If your test ran successfully, you have successfully migrated! You can learn more about using Gradle with Gatling from the following resources: