Hard-coding the number of users, test duration, or target environment URL inside a simulation class means you need to edit and recompile every time those values change. Gatling provides first-class support for passing parameters at launch time — via Java system properties for JVM-based projects and a key=value CLI syntax for the JavaScript SDK. This lets you drive the same simulation file across smoke, capacity, and stress test configurations without touching the source code.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/gatling/gatling.io-doc/llms.txt
Use this file to discover all available pages before exploring further.
Java, Kotlin, and Scala — System Properties
The JVM-based Gatling SDKs read standard Java system properties passed with the-D flag on the command line.
Passing Properties at Launch
- Maven
- Gradle
- sbt
Reading Properties in Your Simulation
UseSystem.getProperty(key, defaultValue) to read each property inside your simulation. Providing a default value ensures the simulation still runs sensibly when a property is omitted (e.g., during a quick local smoke test).
Always parse the string value returned by
System.getProperty into the appropriate type (int, long, double). A NumberFormatException at startup is preferable to silently using a wrong value.JavaScript and TypeScript — CLI Parameters
The Gatling JavaScript CLI uses akey=value format directly on the npx gatling run command. No -D prefix is required.
Passing Parameters at Launch
Reading Parameters with getParameter
Reading Environment Variables with getEnvironmentVariable
For secrets and infrastructure details that should not appear in command-line history, use environment variables instead.
Recommended Patterns
Centralise in a Config class
Create a single
Config utility class that reads all properties and environment variables in one place. Reference Config.USERS throughout the simulation instead of scattering System.getProperty calls.Use meaningful defaults
Set default values that produce a valid smoke test (1 user, short duration). This ensures
mvn gatling:test with no flags always works locally.Document properties in comments
Add a comment block at the top of your simulation listing every accepted property, its type, and its default. Teammates and CI pipelines will thank you.
Combine with test type switching
Use a
testType property to switch between injection profiles (smoke, capacity, soak) so a single simulation file drives all test scenarios from the pipeline.