Inside setUp, choose a Scenario to run based on GUI choice

Hi,

Assume Jenkins passed user choice which Scenario to run to Gatling, how to do it in setUp?

see sample below:

val Scenario1=scenario(“Scenario1”)
.feed(csv1)
.exec(S1.S1Transaction)

val Scenario2=scenario(“Scenario2”)
.feed(csv2)
.exec(S2.S2Transaction)

val Scenario3=scenario(“Scenario3”)
.feed(csv3)
.exec(S3.S3Transaction)

setUp(
// If userChoice is Scenario1, how do make sure only Scenario1 is running
Scenario1.inject(
constantUsersPerSec(5) during(60minutes)
) ,

// If userChoice is Scenario2, how do make sure only Scenario2 is running
Scenario2.inject(
constantUsersPerSec(10) during(60minutes)
) ,
// If userChoice is Scenario3, how do make sure only Scenario3 is running
Scenario3.inject(
constantUsersPerSec(15) during(60minutes)
)
)

Thanks.

You can pass a System property for selecting the proper simulation.

I have a system property, how to use it inside setUp?

Is it okay to use If inside setUp?

setUp(
if (bS1 == true) {
Scenario1.inject(
constantUsersPerSec(5) during(60minutes)
)
}
)

Thanks.

Hi,

This could be a way of doing it. Just remember that the “if” statement in Scala returns a value so you will need to provide an alternative for the other cases.

Cheers!