我正在尝试在 Play 2.0 w/Scala 项目上添加测试:
"Application" should {
"return 404 on the index Action if web is disabled " in {
running(FakeApplication(additionalConfiguration = Map(("enable.webInterface" -> "false")) )) {
Config.IS_WEB_ENABLED must beFalse
val result = controllers.Application.index()(FakeRequest())
status(result) must equalTo(NOT_FOUND)
contentType(result) must beSome("text/html")
charset(result) must beSome("utf-8")
}
}
}
该值Config.IS_WEB_ENABLED
定义为:
object Config {
lazy val IS_WEB_ENABLED = Play.configuration.getBoolean("enable.webInterface").getOrElse(false)
}
正如您所看到的测试,我尝试将配置设置覆盖为enable.webInterface
false,因为application.conf
文件默认设置为 true。但是 FakeApplication 没有获得新的配置值。
知道我在那里缺少什么吗?