加特林使一个方案在一系列方案中运行一次

问题描述 投票:0回答:1

我有一个必须执行某些步骤的情况。但是我不希望用户多次登录。因此,我链接了场景,但是登录仍然发生多次。有什么方法可以限制部分链只运行一次?

class CreateUserSimulation extends Simulation {
val login = Login.getExec()
val userCreate = UserCreate.getExec("basic")
val userJourney = scenario("User Journey")
    .exec(login)
    .exec(userCreate)

setUp(      
    userJourney.inject(constantConcurrentUsers(10) during (2 seconds))
).protocols(Params.httpProtocol)

}

scala gatling
1个回答
0
投票

您需要创建一个变量来说明您是否在系统中

val userJourney = scenario("User Journey")
.exec(_.set(isLogin, "0"))
.doIf(session => session("isLogin").as[String].equals("0")) {
  exec("login")
    .exec(_.set("isLogin", "1"))
}
.exec(userCreate)
© www.soinside.com 2019 - 2024. All rights reserved.