Reputation: 781
I am using PlayFramework 2.5.X
In my Application.conf file I have :
#local DB
db.default.driver=com.mysql.jdbc.Driver
db.default.url=${?DATABASE_URL}
I am also using eclipse. I am trying to edit the DATABASE_URL variable so I can test against my own db. I know I go to Run > Run configurations > [From here Set Environmental Variables]
But which tab should I be looking at, Eclipse Configurations or Java Application
Upvotes: 0
Views: 704
Reputation: 1963
Play allows to use different configuration file for tests. In the test configuration file you can assign different value for any property, existing in application.conf. So, in tests configuration you can set different DB properties.
When you run sbt test, the sbt will take configuration file for tests. If ytou are running tests from eclipse, add to the test run configuration VM argument -Dconfig.file=conf/test.conf
Example of test.conf below inherits all the properties, which are defined in the application.conf. It redefines the default db connection properties: h2 db instead of mySql, defined in the application.conf.
include "application.conf"
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"
db.default.jndiName=DefaultDS
jpa.default=testPersistenceUnit
Upvotes: 2