I externalized some strings to HOCON, on application.conf
. I'm accessing the configuration values like this:
import play.api.Play.current
import play.api.Play.configuration
configuration.getString("foo.bar").get()
As early as possible, to fail fast in case of a missing key, like the docs say.
Now some of my tests that depend on configured objects are failing with a stacktrace that states:
Caused by: java.lang.RuntimeException: There is no started application
I assume this has to do with the configuration? How can I fix this? (tests are specs2)
Do you have a FakeApplication
running? As stated in the documents: http://www.playframework.com/documentation/2.0/JavaTest before you run the test/ test method?
Example from the Wiki:
@Test
public void findById() {
running(fakeApplication(), new Runnable() {
public void run() {
Computer macintosh = Computer.find.byId(21l);
assertThat(macintosh.name).isEqualTo("Macintosh");
assertThat(formatted(macintosh.introduced)).isEqualTo("1984-01-24");
}
});
}
If this is not solving your issue, perhaps providing more information from the Stacktrace would help.
EDIT: Please tag your question carefully, it does not make sense to mention playframework
AND playframework-2.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With