0

I need to change database during test execution. I am first connected to the test database, but at some point I want to connect to another database (external one perhaps), and perform some other tests. Is this possible? If yes, how?

EDIT: I forgot to mention, I'm using Play 1.2.5

2 Answers2

0

If you use JUnit to test, you can make an external config ( file or whatever you want ) refered via parameter and run 2 separate test with 2 config with 2 different string parameter.

Stefano R.
  • 321
  • 1
  • 5
  • 18
0
  1. I would suggest adding following snippet to build.sbt:

    val testConfig = "-Dconfig.file=conf/" + Option(System.getProperty("test.config")).getOrElse("application") + ".conf"
    

    Now you can invoke your tests from console as following:

    activator -Dtest.config="another_conf" test
    

    another_conf defines test datasource. This approach gives flexibility. You can specify different configuration for your local tests as remote (if CI is involved).

  2. Pass extra configuration to fakeApplication() method.

Mon Calamari
  • 4,403
  • 3
  • 26
  • 44