title: How to reset the in memory database in tests with play2, slick3, specs2
body: <p>This is about a play 2.4 app with slick 3.1 using specs 2.
  I use an in-memory db with evolutions during my tests. My problem is this: At the moment, the in-memory database is kept alive for all the tests and is not reset to the initial empty state after each test case.</p>
  
  <p>My current code looks like this: </p>
  
  <pre><code>package test
  
  import play.api.test._
  import play.api.test.Helpers._
  import services.ProjectService
  import scala.concurrent.Await
  import scala.concurrent.duration.Duration
  import org.specs2.mutable._
  import scala.concurrent.ExecutionContext.Implicits.global
  import testhelpers.Injector
  
  
  class ModelSpec extends Specification {
  
    import models._
  
    val projectService = Injector.inject[ProjectService]
  
    "A project" should {
  
      "be inserted" in {
        running(FakeApplication(additionalConfiguration = inMemoryDatabase())) {
  
          val action = projectService.create("A")
            .flatMap(_ =&gt; projectService.all)
  
          val result = Await.result(action, Duration.Inf)
  
          result must be_==(List(Project(1, "A")))
        }
      }
  
      "be inserted2" in {
        running(FakeApplication(additionalConfiguration = inMemoryDatabase())) {
  
          val action = projectService.create("A")
            .flatMap(_ =&gt; projectService.all)
  
          val result = Await.result(action, Duration.Inf)
  
          result must be_==(List(Project(1, "A")))
        }
      }
  
  
    }
  
  }
  </code></pre>
  
  <p>First test passes. Second testfails with the error: List(Project(1,A), Project(2,A)) is not equal to List(Project(1,A)) (ModelSpec.scala:42) because the in-memory database is kept between test cases.</p>
  
  <p>You can find the example project here: <a href="https://github.com/nemoo/play-slick3-example" rel="nofollow">https://github.com/nemoo/play-slick3-example</a></p>
  
  <p>How can i have a fresh database for each test case?</p>