# before and after do not work (not another DSL in before/after post)

**URL:** <https://community.gatling.io/t/before-and-after-do-not-work-not-another-dsl-in-before-after-post/4900>\
**Category:** Gatling (Open-Source)\
**Created:** [April 1, 2019, 8:21pm UTC](https://community.gatling.io/t/before-and-after-do-not-work-not-another-dsl-in-before-after-post/4900 "2019-04-01T20:21:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Admiral\_Akbar](https://avatars.discourse-cdn.com/v4/letter/a/839c29/32.png) [@Admiral\_Akbar](https://community.gatling.io/u/Admiral_Akbar)\
**Post date:** [April 1, 2019, 8:21pm UTC](https://community.gatling.io/t/before-and-after-do-not-work-not-another-dsl-in-before-after-post/4900/1 "2019-04-01T20:21:01Z")

</div>

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:

`

```auto
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:

`

```auto

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)

  }

}

```

`

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [April 1, 2019, 8:36pm UTC](https://community.gatling.io/t/before-and-after-do-not-work-not-another-dsl-in-before-after-post/4900/2 "2019-04-01T20:36:02Z")

</div>

Incorrect syntax, you’re just creating your own methods that we of course don’t call.

[https://gatling.io/docs/current/general/simulation\_structure/#hooks](https://gatling.io/docs/current/general/simulation_structure/#hooks)

---

<div class="post-metadata">

**Author:** ![Admiral\_Akbar](https://avatars.discourse-cdn.com/v4/letter/a/839c29/32.png) [@Admiral\_Akbar](https://community.gatling.io/u/Admiral_Akbar)\
**Post date:** [April 1, 2019, 8:42pm UTC](https://community.gatling.io/t/before-and-after-do-not-work-not-another-dsl-in-before-after-post/4900/3 "2019-04-01T20:42:57Z")

</div>

yep, that would be the something obvious. Thank you for the help.
