我有这个模拟文件。我的想法是创建一个json文件,在json文件中有一些参数。参数将由加特林中的馈线传递值。但问题是当我这样做时,参数不是传递值。
package tci3accountPro
import baseConfig.BaseSimulation
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import tci3accountPro.models.bodyRegisterSubs
import core.api.ApiUtil
import scala.concurrent.duration._
class registerSubscriptions extends BaseSimulation{
val username = "105C169260"
val cashAccount = "11111"
val proCode = "IWEALTH_PRO"
val typeText = "TRIAL"
val referrerId105C = "105C310885"
var ini = new GetTokenApi
val token = ini.getToken(username)
val registerSubs = http.baseUrl(accountProDomain + accountProSubs)
.header("Authorization", token)
.header("Content-Type","application/json")
var feeder = Iterator.continually(Map(
"cashAccount" -> cashAccount,
"code105C" -> username,
"proCode" -> proCode,
"type" -> typeText,
"referrerId105C" -> referrerId105C
))
def registerSub() = {
feed(feeder)
exec(http("register Subscriptions")
.post("")
.body(ElFileBody("bodies/bodyRegisterSubs.json")).asJson
.check(status.is(200)))
}
val scn = scenario("register Subscriptions")
.exec(registerSub)
setUp(scn.inject(atOnceUsers(1),rampUsersPerSec(1) to 5 during (10 seconds)).protocols(registerSubs)).maxDuration(1 minutes)
.assertions(global.responseTime.max.lt(2000), global.successfulRequests.percent.gt(95))
}
和json文件
{
"cashAccount": "${cashAccount}",
"code105C": "${code105C}",
"proCode": "${proCode}",
"type": "${type}",
"referrerId105C": "${referrerId105C}"
}
但是在运行模拟时,它显示:没有定义属性名称“cashAccount”。有人可以帮忙吗?