2

我有以下加特林脚本:

 val wagerFeeder = csv("wagers.csv").random

 val placeBetScenario = scenario("request")
    .feed(wagerFeeder)
.exec(http("send requests")
.post(apiPlaceBet)
    .headers(sentHeaders)
    .body(StringBody(session=>Requests.MyRequest)).asJSON
    .check(status.is(200))
  )

  setUp(
    placeBetScenario.inject(atOnceUsers(1))
  ).protocols(httpConf)

val MyRequest =
    """{
        "playerDetails" : {
          "playerId" : "playerId123"
        },
        "campaignDetails": {
          "campaignId": "dummy-campaign"
        },
        "wagerDetails":{
          "amount" : "${wagerAmount}",
          "currencySymbol": "EUR"
        }
      }"""

赌注.csv 内容:

wagerAmount,wagerCurrency
10,EUR
15,USD

运行后,这似乎 ${wagerAmount} 没有填充并保留占位符字符串

我想念什么?

回复:

Request:
Place bet request: KO status.find.is(200), but actually found 400
=========================
Session:
Session(request,1,Map(gatling.http.cache.dns -> io.gatling.http.resolver.ShuffleJdkNameResolver@1d887911, wagerAmount -> 15, wagerCurrency -> USD),1505806932188,0,KO,List(),<function1>)

stringData={
        "playerDetails" : {
          "playerId" : "playerId123"
        },
        "campaignDetails": {
          "campaignId": "dummy-campaign"
        },
        "wagerDetails":{
          "amount" : "${wagerAmount}",
          "currencySymbol": "EUR"
        }
      }

${wagerAmount} 应该被替换为 15。从日志中看来,加特林确实设法找到了它。但它没有被替换

4

0 回答 0