I have an IntelliJ IDEA project in Scala and started adding org.specs2 tests. I am having trouble finding out how to put in an application.conf file that will be used by the tests.
I have tried doing the following:
test
resources
application.conf
scala
mypackage.myname
MyTestSpec
then called
ConfigFactory.load()
in MyTestSpec. Nothing was loaded, though, neither the application.conf from my resources subfolder of the src folder, nor this one. My goal is to be able to write integration tests against some test environments (please let's not debate the validity of this goal...).
How to go about doing this or is there a better way of going about it? I started reading the specs2 documentation today and I am pretty new to Scala as well so I am just assuming here that this is how test configurations are supposed to work.
So far I have attempted to specify -Dconfig.file=my_test_conf_full path in the build configuration for the tests (from the Build/Configurations... menu in IntelliJ), however that did not make any difference.
Thank you.
Place your custom configuration file at src/test/resources/application.test.conf
.
Then, add this to your build.sbt
:
// When running tests, we use this configuration
javaOptions in Test += s"-Dconfig.file=${sourceDirectory.value}/test/resources/application.test.conf",
// We need to fork a JVM process when testing so the Java options above are applied
fork in Test := true,