如何在重复函数中使用 feeder 值? 我会发送该请求 10 次,之后发送 20 次。 还有另一种方法可以动态地执行此操作吗?
此代码未执行请求。出了什么问题?
CSV:
username,count
foo,10
bar,20
加特林代码:
val times = 0;
private val scn = scenario("BasicSimulation").feed(csvFeeder)
.exec {
session =>
times = session("count").as[Int]
println(times)
session
}
.repeat(times) {
exec(http(s"request").get("https://test.com"))
}
调用
repeat(times)
仅在测试初始化时读取变量一次。 IE。当该值为 0 时,远在您使用 session hook 更改它之前。
repeat
可以采用 EL 字符串,该字符串从 Session
检索值。
以下示例来自文档。
https://gadling.io/docs/gadling/reference/current/core/scenario/#repeat
// with a Gatling EL string resolving an Int
repeat("#{times}") {
exec(http("name").get("/"))
}