我将一些字符串外部化到 HOCON,application.conf
。我正在访问这样的配置值:
import play.api.Play.current
import play.api.Play.configuration
configuration.getString("foo.bar").get()
正如文档所说,尽早,在丢失密钥的情况下快速失败。
现在我的一些测试依赖于配置的对象失败,堆栈跟踪指出:
Caused by: java.lang.RuntimeException: There is no started application
我认为这与配置有关?我怎样才能解决这个问题? (测试是specs2 http://etorreborre.github.com/specs2/)
你有没有FakeApplication
跑步?正如文件中所述:http://www.playframework.com/documentation/2.0/JavaTest http://www.playframework.com/documentation/2.0/JavaTest在运行测试/测试方法之前?
维基百科的例子:
@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");
}
});
}
如果这不能解决您的问题,也许从 Stacktrace 提供更多信息会有所帮助。
编辑:请仔细标记您的问题,提及没有意义playframework
AND playframework-2.0
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)