如何FakeApplication
使用 mydev.conf
而不是 default创建一个来运行我的测试application.conf
?
我当前的测试由以下结构组成:
Map<String, String> map = new HashMap<>();
map.put("config.file", "/path/to/dev.conf");
FakeApplication fakeApplication = fakeApplication(map);
TestServer testServer = testServer(3333, fakeApplication);
// testServer.start();
running(testServer, HTMLUNIT, new F.Callback<TestBrowser>() {
public void invoke(TestBrowser browser) {
//do something
}
});
此代码改编自Play Framework Documentation 关于编写测试会引发以下异常,因为默认值application.conf
在我的开发系统上不起作用。如果我取消注释testServer.start();
,我可以更清楚地看到它。
[WARN] [01/01/2013 18:36:59.505] [pool-4-thread-3] [Dispatchers] Dispatcher [akka.actor.promises-dispatcher] not configured, using default-dispatcher
[WARN] [01/01/2013 18:36:59.521] [play-akka.actor.default-dispatcher-2] [Dispatchers] Dispatcher [akka.actor.actions-dispatcher] not configured, using default-dispatcher
[error] Test test.ApplicationTest.runInBrowser failed: Server is not started!
[error] at scala.sys.package$.error(package.scala:27)
[error] at play.api.test.TestServer.stop(Selenium.scala:117)
[error] at play.test.Helpers.stop(Helpers.java:325)
[error] at play.test.Helpers.running(Helpers.java:355)
[error] at test.ApplicationTest.runInBrowser(ApplicationTest.java:74)
[error] ...
我假设这条线
map.put("config.file", "/path/to/dev.conf");
是错误的,必须适应。但是怎么做?