When the test result is successful, was written resp to the CSV file
When getting the Connection time-out error was not written resp to the CSV file
How can I do this?
val scn = scenario("load test")
.feed(myFeederFirst)
.exec(http("request")
.post("/api/")
.headers(headers_0)
.body(StringBody(
s"""{"amount":"$amount","currency":"$currency","trId":"$trId"}""".stripMargin)).asJson
.check(bodyString.saveAs("resp"))
.check(jsonPath("$.message").saveAs("message"))
.check(jsonPath("$.id").saveAs("id"))
.check(jsonPath("$.code").saveAs("code"))
.check(status.is(200))
.check(jsonPath("$.message").is("Success"))
.check(jsonPath("$.code").is("1000"))
)
.exec(session => {
response_writer.println(session("resp").as[String])
if (session("code").as[String].contains("1000") && session("message").as[String].contains("Success")) {
response_writer2.println("code = " + session("code").as[String] + ",id = " + session("id").as[String] + ",message = " + session("message").as[String] + ",retult = Passed")
} else {
response_writer2.println("code = " + session("code").as[String] + ",id = " + session("id").as[String] + ",message = " + session("message").as[String] + ",retult = Failed")
}
session
})