0
votes

I am new to Scala and Gatling so bear with me! I want to have a for loop inside inject where I can set how many times I want atOnceUsers()instead of just repeating the code x times, but this code is giving me an error so I was wondering if this way is not supported.

val numTimes = 3
val scn = scenario("Some scenario").exec(someScenario)

setUp(
    scn.inject(
        for (i <- 1 to numTimes) atOnceUsers(10)
    ).protocols(httpProtocol)
)
1
What is the error? What specific part of the code (line number) is causing the error? - Kevin Le

1 Answers

0
votes

you're close...

.inject takes an array of steps (which a straight 'for' doesn't produce without a 'yield')

what you can do is...

scn.inject(
    (1 to numTimes).map(i => atOnceUsers(10))
).protocols(httpProtocol)