.feed(json_feeder)
.feed(response_json_feeder)
.exec(http("request_5")
.post("/applications/23")
.headers(headers_1)
.headers(headers_2)
.body(ELFileBody( """../../resources/data/application23.json""")).asJSON
.check(status.is(200))
**.check(jsonPath("$..state").is("GA"))**
**Quick question guys: Can gatling support doing checks as a separate file? Like instead of having it in the DSL have it as a txt file and read it from there?**
Thanks
This will be a new feature in 2.2. It’s already available in the snapshots.
Hey thanks for the quick response. Can I ask you where the snapshots are? And when will 2.2 be available? Thanks again.
Can I ask you where the snapshots are?
Did you check the download page on our site?
And when will 2.2 be available?
ETA is March.
*Stéphane Landelle*
*GatlingCorp CEO*
slandelle@gatling.io
I did look, but I was not sure where the feature would be since there is a lot of snapshots. Thanks.
Use the latest (check the timestamps).
Is there any documentation out there on how one would go about doing the (check file) implementation with the snapshot? Thanks
Hey so I tried out the snapshot and I got this error:
Exception in thread “main” java.lang.ClassCastException: io.gatling.core.body.CompositeByteArrayBody cannot be cast to io.gatling.http.check.HttpCheck
This is what I have on my local:
.pause(2)
.feed(json_feeder)
.exec(http("request_5")
.post("/applications/23")
.headers(headers_1)
.headers(headers_2)
.body(ElFileBody( """../../resources/data/application23.json""")).asJSON
.check(status.is(200))
//.check(jsonPath("$..state").is("LA").saveAs("task"))
//.check(jsonPath("$..isApplyingForFinancialAssistance").is("true").saveAs("task"))
.check(ElFileBody("""../../resources/data/jsonchecks.csv""").asInstanceOf[HttpCheck])
I was wondering if there is a new command in gatling 2.2 to read jsonpaths from a file like I have here? Basically my checks commented here are the ones that I put on the csv file.Thanks.
You didn’t get it right.
In 2.2, you can do something like:
.check(bodyString.is(ElFileBody(“expectedBody.txt”)))
I was wondering if there is a new command in gatling 2.2 to read jsonpaths from a file like I have here? Basically my checks commented here are the ones that I put on the csv file.Thanks.
Even in 2.1, you can pass dynamic JsonPath expressions and expected values.
Stephane thanks for your reply. The bodystring expects an entire body JSON body from what I understand. I want to assert on a specific field. For example,
when I add this to the txt file: .check(jsonPath("$…state").is(“LA”).saveAs(“task”))
I expect the compiler to say for example found “LA” actual should be “GA” and fail the test.
When I do it as a bodystring like you suggested, it looks like is trying to assert on the entire JSON body. I’m not sure if I’m being clear. Let me know if this is possible. Thank you.
For those who are interested, I figured it out:
.pause(2)
.feed(json_feeder)
.exec(actionBuilder = http("request_5")
.post("/applications/23")
.headers(headers_1)
.headers(headers_2)
.body(ElFileBody( """../../resources/data/application23.json""")).asJSON
.check(status.is(200))
.check(jsonPath(ElFileBody("""../../resources/data/jsonchecks.txt"""))
.is(ElFileBody("""../../resources/data/ExpectedResponse.txt""")))
The reason I’m trying to do it this way is that I would like my testers to not code anything on the DSL but just to enter the JSON paths and the expected values as parameters. The challenge is now to read each line on the file separately when doing the assertions. If anyone has any input on how one can do that, it would be great to hear any thoughts. Thank you Stephane you were very helpful.