创建帐户脚本
我怎样才能创建一个加特林脚本create account?创建帐户脚本
我不觉得我怎么可以访问代码的post响应波纹管创建另一个请求的任何实例。
val httpConf = http     .baseURL("http://localhost:3030") // Here is the root for all relative URLs 
    .acceptHeader("application/json") // Here are the common headers 
    val orderRefs = Iterator.continually(
    // Random number will be accessible in session under variable "OrderRef" 
    Map("OrderRef" -> Random.nextInt(Integer.MAX_VALUE)) 
) 
    val scn = scenario("Create Account") // A scenario is a chain of requests and pauses 
    .feed(orderRefs) 
    .exec(http("Create Account Request") 
     .post("/account-request") 
     .body(StringBody("""{"password":"pw${OrderRef}","email":"email${OrderRef}@test.com","firstName":"Name${OrderRef}"}""")).asJSON) 
    setUp(scn.inject(atOnceUsers(10)).protocols(httpConf)) 
在我的例子我想打电话/activate-accont/:token与呼叫上述
回答:
希望这将工作返回的令牌。
.exec(http("Create Account Request")      .post("/account-request") 
     .body(StringBody("""{"password":"pw${OrderRef}","email":"email${OrderRef}@test.com","firstName":"Name${OrderRef}"}""")).asJSON 
     .check(jsonPath("$.Token")).saveAs("myToken")) //Assuming you are getting Token with $.Token 
    ) 
.exec(http("Activate Account") 
     .post("/activate-accont/${myToken}") 
     ....) 
以上是 创建帐户脚本 的全部内容, 来源链接: utcz.com/qa/266887.html

