Knows Not Much Knows Not Much - 2 months ago 4x
Scala Question

Executing Gatling load tests from SBT

I wrote a small web service using Spray framework. I can run it using

sbt run
and then test it in the browser.

Now I wrote a load test using the Gatling framework.

package com.abhi

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._

class LoadTest extends Simulation {
val httpConf = http
.acceptEncodingHeader("gzip, deflate")
.userAgentHeader("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0")

val scn = scenario("BasicSimulation")


The test is located in folder
and the spray code is in

When I run
sbt test
it just prints success without either running my web server or running the test defined above. it just prints success in 3 seconds and gets out.

How can I

  1. ensure that when I do a
    sbt test
    the spray web application is

  2. the galing load test is run against the started server

Edit: I also tried
sbt test scenarios:BasicSimulation
and it threw the error

Not a valid key: BasicSimulation
[error] scenarios:BasicSimulation


You must use the Gatling sbt plugin to trigger from sbt. Beware that it doesn't run in the default configuration but in the gatling one: gatling:test.