Passing Parameters

Using Java options in a Gatling Simulation

You might want to pass parameters from the command line to the Simulation, for example the number of users, the duration of the ramp, etc.

One way is to pass Java System Properties.

The way to pass such System Properties would depend on your launcher:

  • maven: mvn gatling:test -Dusers=500 -Dramp=3600
  • gradle: gradle gatlingRun -Dusers=500 -Dramp=3600
  • sbt: sbt -Dusers=500 -Dramp=3600 Gatling/test
  • Gatling bundle’s gatling.sh or gatling.bat: set the JAVA_OPTS env var, eg JAVA_OPTS="-Dusers=500 -Dramp=3600"

You can then resolve those properties directly in your code:

     
int nbUsers = Integer.getInteger("users", 1);
long myRamp = Long.getLong("ramp", 0);

setUp(scn.injectOpen(rampUsers(nbUsers).during(myRamp)));
val nbUsers = Integer.getInteger("users", 1)
val myRamp = java.lang.Long.getLong("ramp", 0)

setUp(scn.injectOpen(rampUsers(nbUsers).during(myRamp)))
val nbUsers = Integer.getInteger("users", 1)
val myRamp = java.lang.Long.getLong("ramp", 0)

setUp(scn.inject(rampUsers(nbUsers).during(myRamp)))

Edit this page on GitHub