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