Saving generated variables

Hi

As part of my test, I have this call

val r = scala.util.Random


.exec(session => session.set("genEmail", r.nextInt(1000000)))
  .exec(http("Create stuff")
  .post("/someurl")
  .body(StringBody( """{
                          "email": "letstestthis+${genEmail}@gmail.com"
                      }""")).asJSON
  .check(status.is(201)))

In the response, I don't get the email back, so I would like to save the email that is being sent down to a csv. Does anyone have any suggestions on how I could do that? 

Thanks


Hi,

You can feeder to create full email instead of just putting some random int and some code to save it to the file.

val r = scala.util.Random
val feeder = Iterator.continually(Map(“email” → s"lettestthis${r.nextInt(100000)}@gmail.com"))

feed (feeder)
.exec {

  .exec(http("Create stuff")
     .post("/someurl")
     .body(StringBody( """{ "email": "${email}" }""")).asJSON
  .check(status.is(201)))

}
.exec {
session => {
val email = session(“email”).as[String]
// YOUR CODE TO SAVE TO THE CSV
session

}

}

Regards,
Alex.

Aah perfect. Thank you!