I am trying to check the HTTP status and save the status code in a variable, but in Gatling, if I add multiple status checks as follows.
.asJson().check(status().saveAs(RESPONSE_HTTP_STATUS_CODE), status().is(HttpStatus.SC_ACCEPTED)
saveAs function doesn't invoke and RESPONSE_HTTP_STATUS_CODE is always null.
What is the issue here?
Please refer to the following MVP to reproduce the issue.
https://github.com/eranga4u/demo-gatling
PS: I am not a Gatling expert.
The behavior you're observing is completely expected.
You're using exitHereIfFailed
and exitBlockOnFail
in several places in your scenario. When a request is failing, they cause the piece of code you're looking at to be bypassed.