lundi 2 mai 2016

Simple Play Slick Setup for Unit Testing

I used play-slick for Slick integration and Guice to inject DAOs. Evolutions to create tables and populate seed data i.e. 1.sql, 2.sql, .... I am almost complete and I want to split my Evolutions files and application.conf into 2 environments.

I created 2 sets of conf/application.conf and test/conf/application.test.conf pointing to different databases for testing and live deployment. I have setup build.sbt to use application.test.conf for test,

javaOptions in Test += "-Dconfig.file=test/conf/application.test.conf"

application.test.conf content,

slick.dbs.h2test.driver = "slick.driver.H2Driver$"
slick.dbs.h2test.db.driver = org.h2.Driver
slick.dbs.h2test.db.url = "jdbc:test.h2:mem:play;MODE=MYSQL;DB_CLOSE_DELAY=-1"

How do I configure my test cases / suites to use h2test context (ie. conf/evolutions/h2test/1.sql) instead of default to populate test data and run Slick queries again h2test? I tried to use FakeApplication and GuiceApplicationBuilder ways with limited success. Thanks

Aucun commentaire:

Enregistrer un commentaire