How to execute a specific simulation class from gradle command line?

I have multiple gatling simulation classes in a package and I’m running it using a gatling run task for gradle as below:

Kotlin - Gradle project

tasks.register(“run”) {
mainClass.set(“main/MainKt”)
classpath = sourceSets[“main”].runtimeClasspath
args =
listOf(
“-Dproxy=${System.getProperty(“proxy”)}”,
“-Drampuser=${System.getProperty(“rampusers”)}”,
“-Dramptime=${System.getProperty(“ramptime”)}”,
“-Denv=${System.getProperty(“env”)}”,
“-Dcard=${System.getProperty(“card”)}”,
)
}

Getting these custom parameters into Main.kt (main function) and running it using the command
./gradlew run -Dproxy=true …:
val processBuilder =
ProcessBuilder(
“./gradlew”, “gatlingRun”, “-DgatlingSimulationClass=$simulationName”,
“${args.getOrNull(0)}”,
“${args.getOrNull(1)}”,
“${args.getOrNull(2)}”,
“${args.getOrNull(3)}”,
“${args.getOrNull(4)}”
)
val process = processBuilder.start()

Still it’s prompting to choose the simulation file ? Any solution to pass a specific simulation file and run only that simulation class without any interactive prompts in the console
?

You’re reinventing the wheel.
We have an official gradle plugin that does exactly that, eg:

./gradlew gatlingRun --simulation computerdatabase.ComputerDatabaseSimulation -DFOO=BAR

Please stick to the official launchers, we can only help with them, not with custom ones.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.