Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play framework 2.0. Use alternative application.conf in test

my Play using mysql in production. But I am trying to use memory for testing.

I created 2 conf file, 1 is application.conf, the other is application.test.conf (in the same directory).

I tried to do

play -Dconfig.file=conf/application.test.conf test-only

But it still use the default conf file. I'm just wonder if anyone know how to use a different conf file during testing. (or at least use a different database setting during testing).

like image 913
hook38 Avatar asked Mar 13 '13 04:03

hook38


1 Answers

If you mean for unit tests then just add

running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { Test code... }

to your tests and they will be done in memory. No need to change conf files.

like image 152
Jakob Avatar answered Sep 27 '22 18:09

Jakob