Question

I'm working on a playframework project, and we test using scalatest. We also want to do some database tests. In conf/application.conf we set up a database connection, but this seems to be ignored when we launch our tests. How can we configure this?

Was it helpful?

Solution

Your tests needs to be run within the FakeApplication context. You could wrap every test like this (using FunSpec):

describe("MyEntity") {
  it("should do something") {
    running(FakeApplication()) {
      MyEntity.findById(1L).value.name should be("some name")
    }
  }
}

If you don't want to repeat this for every test you can use several methods, see scalatest docs for info about how to share fixures: sharing fixtures

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top