Gatling for loop inside inject

北城以北 提交于 2019-12-25 01:14:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!