2
中播放Logger
V2.3测试不起作用:如何在Play framework v2.3测试中启用记录器?
"Test example" should {
"Test 1" in {
import play.api.Logger
Logger.debug("hello world") // doesn't work, no output on screen
}
}
但如果我WithApplication
包装测试,它的工作原理:
"Test example" should {
"Test 1" in new WithApplication {
import play.api.Logger
Logger.debug("hello world")
}
}
但它给管理费,如果我必须包装使用WithApplication进行每项测试只是为了让Logger工作。
因此,任何人都知道如何让记录器在没有WithApplication的情况下工作?
你从'application.conf启用记录器的例子'? – silentprogrammer 2015-03-03 11:36:13
你在使用['scalatestplus'](http://www.scalatest.org/plus/play)吗?如果是的话,你可以使用['OneServerPerSuite'](http://doc.scalatest.org/plus-play/1.0.0/index.html#org.scalatestplus.play.OneServerPerSuite)或'OneServerPerTest'特性,假应用程序给你的上下文。如果你已经在使用['scalatest'](http://www.scalatest.org),这是一个下降的选择。 – 2015-03-03 11:52:09
@singhakash:是的,如果没有,使用'WithApplication'的第二次测试将不会成功。 @Nader:我使用使用specs2的内置游戏测试库。 – null 2015-03-03 16:36:11