[gatling 2] How to check response body length

Hi!

i need to check the response body if it greater than some predefined value.
How do I make this check using gatling 2.

For example - i make call & check the status code. if status code is 200 - i need to check
response length if it greater than X.

Is there any way to add this metric to generated html report?

Thanks!

Hi,

I tried and got the error:

value greaterThan is not a member of io.gatling.core.check.MatcherCheckBuilder[io.gatling.http.check.HttpCheck,io.gatling.http.response.Response,String,String,Int]

20:22:24.180 [main][ERROR][ZincCompiler.scala:98] i.g.a.ZincCompiler$ - .check(bodyString.transform(.map(.size)).greaterThan(100))
20:22:24.181 [main][ERROR][ZincCompiler.scala:98] i.g.a.ZincCompiler$ - ^
20:22:24.236 [main][ERROR][ZincCompiler.scala:98] i.g.a.ZincCompiler$ - one error found
Exception in thread “main” Compilation failed

oops. looks like ^ sign moved way to the left from it’s place in terminal.
it should be under the “.greaterThan”

woups, sorry, this was missing in M3a and was added in master.

I’ll send you a proper solution for M3a tomorrow.

Cheers,

Stéphane

Myeah. User defined metrics really is a nice feature :slight_smile:

Hi Uladzimir,

Sorry I couldn’t find time to reply today.
Will do tomorrow for sure.

Stéphane

Hi Uladzimir,

Actually, the built-in for “greater than” is already there in M3a, it’s just not directly exposed:

check(bodyString.transform(.map(.size)).matchWith(io.gatling.core.check.Matchers.greaterThan, X)))

Cheers,

Stéphane