Gatling Integration with Play
Published in
3 min readAug 8, 2016
I have started working on a project which require stress testing using Gatling. I Setup the sbt project on which gatling is working fine. But when I try to integrate it using play framework, it doesn’t work. The project structure for both are different so it doesn’t work for both the project in the same manner.
Your build.sbt should be like this:
import _root_.io.gatling.sbt.GatlingPlugin
import _root_.sbt.Keys._name := """play-gatling-tutorial-one"""version := "1.0-SNAPSHOT"lazy val root = (project in file("."))
.enablePlugins(PlayScala)
.enablePlugins(GatlingPlugin)
.configs(GTest)
.settings(inConfig(GTest)(Defaults.testSettings): _*)scalaVersion := "2.11.8"libraryDependencies ++= Seq(
jdbc,
cache,
ws,
"org.scalatestplus.play" %% "scalatestplus-play" % "1.5.1" % Test,
"io.gatling.highcharts" % "gatling-charts-highcharts" % "2.2.2" % "test",
"io.gatling" % "gatling-test-framework" % "2.2.2" % "test")resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"lazy val GTest = config("gatling") extend (Test)scalaSource in GTest := baseDirectory.value / "/gatling/simulation"
/*In this line we are just configuring to take all the gatling test cases
from the "gatling/simulation" folder of the base directory.*/
and plugins.sbt should be like this://gatling plugin++++
addSbtPlugin("io.gatling" % "gatling-sbt" % "2.2.0")// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.4")// web pluginsaddSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0")addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.2")
You need to create a folder in your base directory eg. gatling, and make conf and simulation folder in that directory. In conf folder put your gatling configuration file and in simulation folder put all your gatling test scenarios.Your folder structure should be like this:app → Application sources
build.sbt → Application build script
conf → Configurations files
└ application.conf → Main configuration file
└ routes → Routes definition
gatling
└ conf
└ gatling.conf → Configuration file of gatling
└ simulation → Put all your gatling test in this folder
└ GatlingTest
public → Public assets
project → sbt configuration files
└ build.properties → Marker for sbt project
└ plugins.sbt → sbt plugins including play declaration
testTo run the gatling test case you need to run activatorthen ,gatling: test to run all the test cases.
Your result would look line this:
Gatling Report on browser would be like this:/home/sid/Desktop/play-gatling-tutorial-one/target/gatling/gatlingtest-1470402193130/index.html
To clone the Project visit on my Github Gatling with play