Integration Test Configuration in Play Framework

Table of contents
Reading Time: < 1 minute

A few days ago I’ve come across a problem while writing integration testing of my play application. My need was like to run unit and Integration test separately, in a normal sbt project, it’s easy to configure it, but I couldn’t find proper documentation about how to do this in play application, because there are difference in the folder structure in both of them.
The reason why I wanted to run unit and integration test cases separately because my integration tests take much more time as they call external web services.
So I came to know one easy solution, which I am going to explain, There are only 2 steps to do this.
1. You need to create a folder in your base directory eg. it, and put your all Integration test cases in that folder.

2. You need to configure your build.sbt file so it can understand where are all integration tests are placed

lazy val root = (project in file("."))
  .settings(routesGenerator := InjectedRoutesGenerator)
  .settings( inConfig(ITest)(Defaults.testSettings) : _*)

lazy val ITest = config("it") extend(Test)

scalaSource in ITest := baseDirectory.value / "/it"

On the last line of code we are just configuring to take all integration test cases from the “it” folder of the base directory.

So that’s it 🙂
You just need to hit it:test to run integration tests and simple test  to run the unit test cases.


1 thought on “Integration Test Configuration in Play Framework1 min read

Comments are closed.