问题
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:
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)
来源:https://stackoverflow.com/questions/56532943/gatling-for-loop-inside-inject