1

次のように、プレイ プロジェクトで最小限の統合テストを実行します。

@Test
public void test() {
    Logger.info("start integration test");
    running(testServer(3333, fakeApplication(inMemoryDatabase())), FIREFOX, new Callback<TestBrowser>() {
        public void invoke(TestBrowser browser) {
            Logger.info("invoke test browser");
            browser.goTo("http://localhost:3333/linklist");
            assertThat(browser.pageSource()).contains("Some string in my page");
        }
    });
}

main->frontend->commonプロジェクトをサブプロジェクト (と)に分割しましたmain->backend->common。統合テストはメイン プロジェクトで実行されます。

編集済み

試運転では までbrowser.goTo("http://localhost:3333/linklist");到達し、45 秒後に停止します。

Firefox が開きますが、何も起こりません。しかし、私は自分自身に URL を置くことができ、http://localhost:3333/linklistこのようにページに移動します。

browserインスタンスが開くものと同じではないようです。

エラーメッセージは次のとおりです。

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
    *** LOG addons.manager: Application has been upgraded
    *** LOG addons.xpi: startup
    *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
    *** LOG addons.xpi: checkForChanges
    *** LOG addons.xpi-utils: Opening database
    *** LOG addons.xpi-utils: Creating database schema
    *** LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile
    *** LOG addons.xpi: New add-on langpack-en-ZA@firefox.mozilla.org installed in app-global
    *** LOG addons.xpi: New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
    *** LOG addons.xpi: New add-on langpack-en-GB@firefox.mozilla.org installed in app-global
    *** LOG addons.xpi: New add-on globalmenu@ubuntu.com installed in app-global
    *** LOG addons.xpi: New add-on langpack-de@firefox.mozilla.org installed in app-global
    *** LOG addons.xpi: New add-on ubufox@ubuntu.com installed in app-system-share
    *** LOG addons.xpi: Updating database with changes to installed add-ons
    *** LOG addons.xpi-utils: Updating add-on states
    *** LOG addons.xpi-utils: Writing add-ons list
    *** LOG addons.manager: shutdown
    *** LOG addons.xpi: shutdown
    *** LOG addons.xpi-utils: shutdown
    *** LOG addons.xpi-utils: Database closed
    *** LOG addons.xpi: startup
    *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
    *** LOG addons.xpi: checkForChanges
    *** LOG addons.xpi: No changes found

        at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:109)
        at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:245)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:109)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:183)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:178)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:174)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at java.lang.Class.newInstance0(Class.java:374)
        at java.lang.Class.newInstance(Class.java:327)
        at play.api.test.WebDriverFactory$.apply(Selenium.scala:95)
        at play.api.test.WebDriverFactory.apply(Selenium.scala)
        at play.test.TestBrowser.<init>(TestBrowser.java:24)
        at play.test.Helpers.testBrowser(Helpers.java:467)
        at play.test.Helpers.testBrowser(Helpers.java:459)
        at play.test.Helpers.running(Helpers.java:427)
        at frontend.IntegrationTest.test(IntegrationTest.java:27)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at org.junit.runners.Suite.runChild(Suite.java:128)
        at org.junit.runners.Suite.runChild(Suite.java:24)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
        at com.novocode.junit.JUnitRunner.run(JUnitRunner.java:84)
        at sbt.ForkMain$Run.runTests(ForkMain.java:155)
        at sbt.ForkMain$Run.run(ForkMain.java:169)
        at sbt.ForkMain.main(ForkMain.java:84)
    [error] Test frontend.IntegrationTest.test failed: org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows: 
    [error] *** LOG addons.manager: Application has been upgraded
    [error] *** LOG addons.xpi: startup
    [error] *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
    [error] *** LOG addons.xpi: checkForChanges
    [error] *** LOG addons.xpi-utils: Opening database
    [error] *** LOG addons.xpi-utils: Creating database schema
    [error] *** LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile
    [error] *** LOG addons.xpi: New add-on langpack-en-ZA@firefox.mozilla.org installed in app-global
    [error] *** LOG addons.xpi: New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
    [error] *** LOG addons.xpi: New add-on langpack-en-GB@firefox.mozilla.org installed in app-global
    [error] *** LOG addons.xpi: New add-on globalmenu@ubuntu.com installed in app-global
    [error] *** LOG addons.xpi: New add-on langpack-de@firefox.mozilla.org installed in app-global
    [error] *** LOG addons.xpi: New add-on ubufox@ubuntu.com installed in app-system-share
    [error] *** LOG addons.xpi: Updating database with changes to installed add-ons
    [error] *** LOG addons.xpi-utils: Updating add-on states
    [error] *** LOG addons.xpi-utils: Writing add-ons list
    [error] *** LOG addons.manager: shutdown
    [error] *** LOG addons.xpi: shutdown
    [error] *** LOG addons.xpi-utils: shutdown
    [error] *** LOG addons.xpi-utils: Database closed
    [error] *** LOG addons.xpi: startup
    [error] *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
    [error] *** LOG addons.xpi: checkForChanges
    [error] *** LOG addons.xpi: No changes found
    [error] 
    [error] Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 22:18:01'
    [error] System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.5.0-28-generic', java.version: '1.7.0_21'
    [error] Driver info: driver.version: FirefoxDriver
    [error]     at play.test.Helpers.running(Helpers.java:430)
    [error]     at frontend.IntegrationTest.test(IntegrationTest.java:27)
    [error]     ...
    [error] Caused by: org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows: 
    [error] *** LOG addons.manager: Application has been upgraded
    [error] *** LOG addons.xpi: startup
    [error] *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
    [error] *** LOG addons.xpi: checkForChanges
    [error] *** LOG addons.xpi-utils: Opening database
    [error] *** LOG addons.xpi-utils: Creating database schema
    [error] *** LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile
    [error] *** LOG addons.xpi: New add-on langpack-en-ZA@firefox.mozilla.org installed in app-global
    [error] *** LOG addons.xpi: New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
    [error] *** LOG addons.xpi: New add-on langpack-en-GB@firefox.mozilla.org installed in app-global
    [error] *** LOG addons.xpi: New add-on globalmenu@ubuntu.com installed in app-global
    [error] *** LOG addons.xpi: New add-on langpack-de@firefox.mozilla.org installed in app-global
    [error] *** LOG addons.xpi: New add-on ubufox@ubuntu.com installed in app-system-share
    [error] *** LOG addons.xpi: Updating database with changes to installed add-ons
    [error] *** LOG addons.xpi-utils: Updating add-on states
    [error] *** LOG addons.xpi-utils: Writing add-ons list
    [error] *** LOG addons.manager: shutdown
    [error] *** LOG addons.xpi: shutdown
    [error] *** LOG addons.xpi-utils: shutdown
    [error] *** LOG addons.xpi-utils: Database closed
    [error] *** LOG addons.xpi: startup
    [error] *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
    [error] *** LOG addons.xpi: checkForChanges
    [error] *** LOG addons.xpi: No changes found
    [error] 
    [error] Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 22:18:01'
    [error] System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.5.0-28-generic', java.version: '1.7.0_21'
    [error] Driver info: driver.version: FirefoxDriver
    [error]     at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:121)
    [error]     at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:245)
    [error]     at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:109)
    [error]     at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:183)
    [error]     at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:178)
    [error]     at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:174)
    [error]     at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)
    [error]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    [error]     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    [error]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    [error]     at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    [error]     at java.lang.Class.newInstance0(Class.java:374)
    [error]     at java.lang.Class.newInstance(Class.java:327)
    [error]     at play.api.test.WebDriverFactory$.apply(Selenium.scala:95)
    [error]     at play.api.test.WebDriverFactory.apply(Selenium.scala)
    [error]     at play.test.TestBrowser.<init>(TestBrowser.java:24)
    [error]     at play.test.Helpers.testBrowser(Helpers.java:467)
    [error]     at play.test.Helpers.testBrowser(Helpers.java:459)
    [error]     at play.test.Helpers.running(Helpers.java:427)
    [error]     ... 32 more
    [error] Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
    [error] *** LOG addons.manager: Application has been upgraded
    [error] *** LOG addons.xpi: startup
    [error] *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
    [error] *** LOG addons.xpi: checkForChanges
    [error] *** LOG addons.xpi-utils: Opening database
    [error] *** LOG addons.xpi-utils: Creating database schema
    [error] *** LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile
    [error] *** LOG addons.xpi: New add-on langpack-en-ZA@firefox.mozilla.org installed in app-global
    [error] *** LOG addons.xpi: New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
    [error] *** LOG addons.xpi: New add-on langpack-en-GB@firefox.mozilla.org installed in app-global
    [error] *** LOG addons.xpi: New add-on globalmenu@ubuntu.com installed in app-global
    [error] *** LOG addons.xpi: New add-on langpack-de@firefox.mozilla.org installed in app-global
    [error] *** LOG addons.xpi: New add-on ubufox@ubuntu.com installed in app-system-share
    [error] *** LOG addons.xpi: Updating database with changes to installed add-ons
    [error] *** LOG addons.xpi-utils: Updating add-on states
    [error] *** LOG addons.xpi-utils: Writing add-ons list
    [error] *** LOG addons.manager: shutdown
    [error] *** LOG addons.xpi: shutdown
    [error] *** LOG addons.xpi-utils: shutdown
    [error] *** LOG addons.xpi-utils: Database closed
    [error] *** LOG addons.xpi: startup
    [error] *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
    [error] *** LOG addons.xpi: checkForChanges
    [error] *** LOG addons.xpi: No changes found
    [error]     at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:109)
    [error]     ... 50 more
    [info] frontend.IntegrationTest
    [info] x frontend.IntegrationTest.test
    [info] 
    [info] 
    [info] Total for test frontend.IntegrationTest
    [info] Finished in 0.01 seconds
    [info] 1 tests, 1 failures, 0 errors
    [error] Failed: : Total 1, Failed 1, Errors 0, Passed 0, Skipped 0
    [error] Failed tests:
    [error]     frontend.IntegrationTest
    [error] (myapp/test:test-only) Tests unsuccessful
    [error] Total time: 58 s, completed May 3, 2013 4:09:49 PM
4

1 に答える 1

1

私は問題を発見しました:

  • 最初にHTMLUNITで試しましたが、これはjavascriptでは機能しないため、FIREFOXに変更しました
  • 次に、Firefoxのバージョン(20)が新しいという問題があったため、バージョン15にダウングレードしました

これで、統合テストが正常に動作します!

于 2013-05-05T13:00:04.163 に答える