Run Gatling Script from command Line - With Parameters


I have a scenario where the developer is given option to cherry-pick the page that he wants to test towards end of the build.

So, my idea is to have multiple classes in same simulation and execute them based on the developer choice through parameter values from Jenkins.

For example, I did the same using another open source Load testing tools where the page requests are all scripted to be executed based on the Boolean value if the developer selected it or not on Jenkins.

On Gatling, to avoid the prompt of selecting a simulation on the command line, i added the class name direcly in the properties file and the it works perfectly. But the requirement is extended to have a choice of classes as a user input. So, i want to know if there is a command line argument that I can pass for selecting the class to be executed rather than updating properties file.


Try using -Dgatling.simulationClass, like this:
gatling:execute -Dgatling.simulationClass=com.mycompany.mytest

Not Sure , if I am doing it right though. I am using Gatling 2.25 & on trying to test on Windows. Tried twice. Can you provide the complete command?

D:\Temp\Gatling\gatling225\gatling225\bin>gatling:execute -Dgatling.simulationClass=companyTest
The filename, directory name, or volume label syntax is incorrect.

*D:\Temp\Gatling\gatling225\gatling225\bin>gatling.bat -Dgatling.simulationClass=*companyTest
GATLING_HOME is set to “D:\Temp\Gatling\gatling225\gatling225”
JAVA = “java”
*Error: Unknown option -Dgatling.simulationClass=*companyTest
Try --help for more information.


Sorry if my suggestion was too brief.

Since you mentioned executing it from Jenkins I assumed you were executing Gatling using maven and the gatling-maven-plugin. What I am writing here only applies to using maven.

In my pom.xml I use the gatling-maven-plugin, like so:

io.gatling gatling-maven-plugin 2.2.4 true true integration-test execute

If you launch your gatling project using mvn gatling:execute and no further options with the above configuration Gatling will execute all your simulation classes one after another. However, if you pass -Dgatling.simulationClass=com.mycompany.mytest (literally execute it like this: mvn gatling:execute -Dgatling.simulationClass=com.mycompany.mytest) it will only execute the Gatling simulation found in the class com.mycompany.mytest.

This is how we execute Gatling tests. The same Gatling project provides several simulation classes and we set up different Jenkins jobs to execute them separately using the -Dgatling.simulationClass property.

I hope that helps.

Yes, so that was the case with maven i found from few Google searches.

But my case is different where I need the test to be executed through a command line statement from a Windows/Linux machine.

I hope someone has an answer :slight_smile:


During test development I execute the tests on my Windows machine from the command prompt (with maven) using exactly this technique. For each Gatling project I have a set of Run Configurations set up in IntelliJ so I can execute the tests directly from my development environment.

I do not see the problem here, especially since you use Jenkins already?

Also, a quick glance at the documentation for Gatling reveals that you can pass --simulation to do the same thing.

Good luck.

I sorted this just few minutes before I got your reply :slight_smile: by using ‘-s’ for passing class name and using JAVA_OPTS for passing values like users, iterations, request selections.

However, that seems not to be working on Windows but working like a charm on Linux.

Thanks for the support though :slight_smile: