Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Using an in-memory database for Play! framework testing
class TestCountriesSpec extends Specification {
val appWithMemoryDatabase = FakeApplication(additionalConfiguration = inMemoryDatabase())
abstract class WithDbData extends WithApplication(appWithMemoryDatabase) {
override def around[T: AsResult](t: => T): Result = super.around {
def setupData() {
AppDB.database.withSession { implicit session: Session =>
"Countries" should {
// Model tests
"be found by country id" in new WithDbData {
val country = AppDB.dal.Countries.findOne(1) aka "must have a name of Brazil" must equalTo("Brazil")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment