I am performance testing a Play! application which contains a number of GET/POST API's. I want to do some debugging as one single test is mysteriously failing out of hundreds (and it only fails when the whole lot is run). How do I conditionally add println's if the status returned is 500?
I have tried the following, but since session.status
isn't an Int it isn't working (ie it always returns false). Also, I don't think that checking session.status
is even the right thing to do as when I just print out session.status
for every call, it just spits a bunch of lines of OK
(not even SEE_OTHER
or something similar like I would expect it to be for the successful runs), but I'm not sure what the alternative is.
val postData: ChainBuilder = exec(http(s"[POST] Data sent to API")
.post(s"$baseUrl/post-data")
.formParam("id", s"$${id}")
.check(status.is(303))
.disableFollowRedirect)
.exec {
session =>
if (session.status == 500) {
println(session.attributes("id")) // whatever
}
session
}
I'm not sure how to do this if
check, or where to put it. How do I conditionally check some data within my tests, based on the status
of the result?