I have a series of Specs2 test files, each in the following form:
class NetworkToolsIT extends PlaySpecification {
sequential
val databaseName = "xxxx"
val addConf = Map(...)
val application = FakeApplication(additionalConfiguration = addConf)
val server = TestServer(port = 8888, application)
step(server.start())
step(resetDB(databaseName))
"My test" should {
"test 1" in {
...
}
"test 2" in {
...
}
}
step(server.stop())
}
My problem is that if I run each specs2 file separately, they all succeed. On the contrary running them all together (with sbt test
) they fail.
This issue is related to the fact that I'm using singleton objects as DAOs (as explained in this post)
I would like to know if there is a way to explicitly destroy a FakeApplication
once the test is finished, so that different test files are executed as if they were run separately.
I tried adding this to my project configuration, but it didn't work.
parallelExecution in Test := false
I also tried to add this to at the end of each test file:
step(play.api.Play.stop())
but didn't work.
P.S. I'm using Play! 2.3.7