However even though I’ve updated my gatling version I don’t see to find a way to use this feature and it seems to be missing an entry into the cheat sheet:
\CanaryPage.scala:16: missing argument list for method checkIf in trait CheckSupport
Unapplied methods are only converted to functions when a function type is expected.
You can make this conversion explicit by writing checkIf _ or checkIf(_)(_)(_) instead of checkIf.
I don’t understand what the compiler is trying to tell me to do. I’m scala ignorant and I have stared at the documentation for hours trying to figure out how to use a checkIf to no avail.
My mistake, I check, indeed it don’t works, because checkIf is a wrapper and don’t chain.
The signature with an Expression[Boolean] seems not to be visible, you have to use (Response, Session) => Validation[Boolean] instead.
So indeed the first form is hard to make compile.
You’d have to help the Scala compiler and provide some types explicitly, case is too complicated for it to infer them.
Or maybe some nested solution as I thought at first:
exec(http(“my_test”)
.get("/myurl)
.checkIf(status.is(201)) //this requires the next command to be a “check”
.check(jsonPath("…").exists) //regular check only executed in case of success of the previous one, in a negative case is just bypassed
.check(jsonPath(“anotherpath”).exists) //non conditional regular check
This feature will probably be completely rebooted in Gatling 3, along with the checks.
And yes, there’s a good chance the first parameter will be a check, just like it’s being doing with the “matching” condition in the future WebSocket API.
By the way, Marcelo, you can avoid the first check which save the response status code, since you have access to the response in the checkIf argument function.