title: Modularising scenarios to run in sequence using Gatling
body: <p>I'm trying to modularise a series of performance tests in Gatling.</p>
  
  <p>Several of the tests execute the same initial path through the pages, so I thought that I could break them down into a series of scenarios, each scenario being a series of shared actions defined in its own file, and then a final Simulation definition that simply executed the specified scenarios one after the other.</p>
  
  <p>What I then need is for my Simulation to run those scenarios in sequence; but I can only find how to run them either concurrently, or with a specified delay between each. Is there any Simulation setup option to run the defined scenarios one after the other without specifying an arbitrary delay?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Currently, I have the following set of files:</p>
  
  <p>homepageHeaders.scala</p>
  
  <pre><code>package advanced
  
  object homepageHeaders {
  
      val homepage_headers_1 = Map(
          "Accept" -&gt; """text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8""",
          "If-Modified-Since" -&gt; """Wed, 20 Mar 2013 15:36:31 +0000""",
          "If-None-Match" -&gt; """"1363793791""""
      )
  
  }
  </code></pre>
  
  <p>homepageChain.scala</p>
  
  <pre><code>package advanced
  import com.excilys.ebi.gatling.core.Predef._
  import com.excilys.ebi.gatling.http.Predef._
  import com.excilys.ebi.gatling.jdbc.Predef._
  import akka.util.duration._
  import homepageHeaders._
  
  
  object homepageChain {
  
      val homepageChain = 
          //Homepage
          exec(http("homepage")
                      .get("/")
                      .headers(homepageHeaders.homepage_headers_1)
              )
  
  }
  </code></pre>
  
  <p>pageHeaders.scala</p>
  
  <pre><code>package advanced
  
  object pageHeaders {
  
      val page_headers_1 = Map(
              "Accept" -&gt; """text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"""
      )
  
  }
  </code></pre>
  
  <p>pageChain.scala</p>
  
  <pre><code>package advanced
  import com.excilys.ebi.gatling.core.Predef._
  import com.excilys.ebi.gatling.http.Predef._
  import com.excilys.ebi.gatling.jdbc.Predef._
  import akka.util.duration._
  import pageHeaders._
  
  
  object pageChain {
  
      val pageChain = 
          //Page Menu
          exec(http("page request")
                      .get("/page1")
                      .headers(pageHeaders.page_headers_1)
              )
  
  }
  </code></pre>
  
  <p>pageSimulation.scala</p>
  
  <pre><code>package advanced
  import com.excilys.ebi.gatling.core.Predef._
  import com.excilys.ebi.gatling.http.Predef._
  import com.excilys.ebi.gatling.jdbc.Predef._
  import homepageChain._
  import pageChain._
  
  class pageSimulation extends Simulation {
  
      val urlBase = "http://www.mytestsite.com"
  
      val httpConf = httpConfig
              .baseURL(urlBase)
              .acceptHeader("image/png,image/*;q=0.8,*/*;q=0.5")
              .acceptEncodingHeader("gzip, deflate")
              .acceptLanguageHeader("en-gb,en;q=0.5")
              .userAgentHeader("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0")
  
      val pageScenario = scenario("Bodycare Scenario")
          .exec(homepageChain.homepageChain)
          .exec(pageChain.pageChain)
  
  
      setUp(
              homepageScenario.users(1).protocolConfig(httpConf)
          )
  }
  </code></pre>
  
  <p>The error that I'm getting is:</p>
  
  <pre><code>14:40:50.800 [ERROR] c.e.e.g.a.ZincCompiler$ - /Gatling/user-files/simulations/advanced/pageChain.scala:13: not found: value exec
  14:40:50.807 [ERROR] c.e.e.g.a.ZincCompiler$ -          exec(http("page request")
  14:40:50.808 [ERROR] c.e.e.g.a.ZincCompiler$ -          ^
  14:40:53.988 [ERROR] c.e.e.g.a.ZincCompiler$ - /Gatling/user-files/simulations/advanced/homepageChain.scala:13: not found: value exec
  14:40:53.989 [ERROR] c.e.e.g.a.ZincCompiler$ -          exec(http("homepage")
  14:40:53.989 [ERROR] c.e.e.g.a.ZincCompiler$ -          ^
  14:41:17.274 [ERROR] c.e.e.g.a.ZincCompiler$ - two errors found
  Exception in thread "main" Compilation failed
  </code></pre>
  
  <p>Clearly I'm missing something in my definition, but I just don't understand what it is</p>