本文介绍了加注循环内部注入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Scala和Gatling的新手,所以请多多包涵!我想在inject中有一个for循环,可以在其中设置我想要atOnceUsers()的次数,而不仅仅是重复代码x次,但是这段代码给我一个错误,所以我想知道是否不支持这种方式./p>

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)
)

推荐答案

您将关闭...

.inject采取一系列步骤(没有"yield"就不会产生直接的"for")

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

你能做的是...

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

这篇关于加注循环内部注入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 06:25