Reputation: 9586
Documented here, Gatling's checkIf
method is intended for conditional checking. It's not available on ScenarioBuilder
's fluent API but I can see it in the CheckSupport
class. I have scoured the internet and cannot find a single example.
I'm using Gatling 2.3.1.
Upvotes: 4
Views: 6179
Reputation: 1026
Under Gatling 3.7.6, this worked for me:
http("Test Gatling checkIf()")
.get("/")
.check(status().in(200, 404).saveAs("httpStatus"))
.checkIf(session -> "200".equals(session.getString("httpStatus")))
.then(
jmesPath("someField")
.saveAs("fieldName"))
.checkIf(session -> "404".equals(session.getString("httpStatus")))
.then(
jmesPath("someField")
.withDefault("some default value")
.saveAs("fieldName"));
Upvotes: 0
Reputation: 9586
I found an example in their unit tests as follows:
http("untypedCheckIf").get("/")
.check(
checkIf("${bool}") {
jsonPath("$..foo")
}
)
Upvotes: 14