我有一个必须执行某些步骤的情况。但是我不希望用户多次登录。因此,我链接了场景,但是登录仍然发生多次。有什么方法可以限制部分链只运行一次?
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)
}
您需要创建一个变量来说明您是否在系统中
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)