So I am well aware we can’t do DSL things in the before/after, but it looks like they do not even fire. From the below code in Gatling 3.0 I do not get the println statements and I do not reach the breakpoints in intellij. I have to be missing something pretty obvious here.
My Simulation:
`
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class Sample extends Simulation {
val httpProtocol = http
.baseUrl("https://www.google.com")
.inferHtmlResources()
val headers_0 = Map(
"accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"accept-encoding" -> "gzip, deflate, br",
"accept-language" -> "en-US,en;q=0.9",
"cache-control" -> "max-age=0",
"upgrade-insecure-requests" -> "1",
"user-agent" -> "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36")
def before = {
println("In the Before")
}
def after = {
println("All done!")
}
val scn = scenario("Sample")
.exec(http("request_0")
.get("/")
.headers(headers_0)
)
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}
`
In case it matters I am running the simulation via a object. See below:
`
import io.gatling.app.Gatling
import io.gatling.core.config.GatlingPropertiesBuilder
object temp {
def main(args: Array[String]): Unit = {
val simulation = classOf[Sample].getName
val runner = new GatlingPropertiesBuilder
runner.simulationClass(simulation)
Gatling.fromMap(runner.build)
}
}
`