Hi, I am trying to use the “doIf” feature, but it does not working.
I am using Gatling 2.0.0-RC3 version.
the error message is:
11:57:24.577 [ERROR] i.g.a.ZincCompiler$ - gatling/user-files/simulations/harpia/Startup.scala:23: value doIf is not a member of io.gatling.http.request.builder.HttpRequestWithParamsBuilder
possible cause: maybe a semicolon is missing before `value doIf’?
11:57:24.579 [ERROR] i.g.a.ZincCompiler$ - .doIf("${database_name}", “${database}”) {
11:57:24.580 [ERROR] i.g.a.ZincCompiler$ - ^
11:57:24.616 [ERROR] i.g.a.ZincCompiler$ - one error found
It looks like you’re missing a right parenthensis somewhere in your scenario, as you’re seemingly trying to call doIf on a http(…) request instead of a exec(…) block.
val scn = scenario(“Insertions”) // Cria o database
.feed(feederConfig)
.exec(http(“createDB”)
.post("/v1/databases")
.body(StringBody(""""{ “database_name”:${database} }""")).asJSON
.check(jsonPath("$[0].database_name").saveAs(“database_name”))) <— Missing parenthesis right here: first one close saveAs(…), second one close check(…), exec wasn’t closed.
.doIfOrElse("${database_name}", “${database}”) {
println(“Database created.”)
} {
println(“Database already created.”)
}
)
Is possible instead of use “check(…)” use other form to store information in some variable to use in the “doIf”??
Because if the “check” fail it returns an error. Like the check by status code = 201.
In your gist, there’s a missing “)” just before your .doIfOrElse in order to close the exec for the request.
Then, if your use doIfOrElse, you have to provide the alternative for the else. Otherwise, just use a doIf.