dimanche 29 novembre 2015

Testing Play + Slick app

I've a simple CRUD app built with Scala Play 2.4.3 and Play-slick 1.1.0 (slick 3.1.0) that uses a MySQL database for persistent storage.

I was trying to create the tests for my app and I saw 2 main options:

  • mocking database access, that as far as I've seen, requires some code changes
  • make tests use an alternative database (probably, in memory H2).

What's the best approach (vantages and desavantages)?

I prefer the second approach, but I'm finding some difficulties in setting up the tests.

What do I need to do? First, I think that I need to do the tests run with a FakeApplication, right? Do I need any sbt dependency to be able to do that?

After that, how do I specify to use the H2 database?

Aucun commentaire:

Enregistrer un commentaire