0
我發現使用WithBrowser
失敗,如果我提供了集成測試我自己FakeApplication
:播放2.3.6 - 提供FakeApplication到WithBrowser(APP = ...)打破測試
@RunWith(classOf[JUnitRunner])
class IntegrationSpec extends Specification {
"Application" should {
"work from within a browser" in new WithBrowser(app = FakeApplication()) {
browser.goTo("http://localhost:" + port)
browser.pageSource must contain("Some text from my frontpage")
}
}
我總是得到一個空白頁:
'<?xml version="1.0" encoding="UTF-8"?>
<html>
<head/>
<body/>
</html>
' doesn't contain 'Some text from my frontpage'
任何意見,將不勝感激。
這很奇怪,因爲你沒有做任何特別的事情 - 如果你看看[源代碼](https://github.com/playframework/playframework/blob/2.3.x/framework/src/play-test /src/main/scala/play/api/test/Specs.scala#L48),你會發現'app'參數的默認值是'FakeApplication'的一個實例,就像你的代碼一樣。 – tokarev