I am trying to configure the play framework application to load so that it uses the mysql database at startup and the memory database for tests. When I run the tests, it connects to the mysql database, not the memory database. Does anyone know why?
This is my configuration:
db.default.driver=com.mysql.jdbc.Driver db.default.url="jdbc:mysql://localhost/communityRoots?characterEncoding=UTF-8" db.default.user=root db.default.password= "" db.test.driver=org.h2.Driver db.test.url="jdbc:h2:mem:play;MODE=MYSQL" db.test.user=sa db.test.password=""
this is my test:
running(fakeApplication(inMemoryDatabase("test")), new Runnable() { public void run() { new User("bob@gmail.com", "Bob", "secret").save(); assertNotNull(User.authenticate("bob@gmail.com", "secret")); assertNull(User.authenticate("bob@gmail.com", "badpassword")); assertNull(User.authenticate("tom@gmail.com", "secret")); } });
java database mysql junit playframework
Ciaran0
source share