Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Demonstrating Gatling foreach loop works as expected
package io.gatling.demo.work
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class ForEachSimulation extends Simulation {
val cl = List("apple", "dell")
val scn = scenario("test")
.foreach(cl, "name") {
exec(http("getvalues ${name}").get("https://gatling.io/getName/${name}"))
}
setUp(scn.inject(atOnceUsers(1)))
}
================================================================================
2020-07-30 16:02:41 0s elapsed
---- Requests ------------------------------------------------------------------
> Global (OK=0 KO=2 )
> getvalues apple (OK=0 KO=1 )
> getvalues dell (OK=0 KO=1 )
---- Errors --------------------------------------------------------------------
> status.find.in(200,201,202,203,204,205,206,207,208,209,304), f 2 (100.0%)
ound 404
---- test ----------------------------------------------------------------------
[##########################################################################]100%
waiting: 0 / active: 0 / done: 1
================================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment