1
votes

When attempting to run integration tests, I've run into a baffling problem where the JVM will hang, using 100% of the CPU. The test that comes with the new Play application works correctly, but as soon as it requires database interaction, it will hang indefinitely. For all other unit tests, everything runs smoothly connecting to a mysql database on localhost. I'd like to be able to use that same setup with my integration tests.

Here is an example of a test that will hang upon calling browser.goTo("/")

import org.specs2.mutable._

import play.api.test._
import play.api.test.Helpers._

class TestSpec extends Specification {

  "Application" should {

    "work from within a browser" in new WithBrowser(webDriver = HTMLUNIT, app = FakeApplication()) {

      browser.goTo("/")

      println(browser.pageSource)

      browser.$("#email").text("[email protected]")
      browser.$("#password").text("password")
      browser.$("#loginbutton").click()
      browser.pageSource must not contain("Sign in")
      browser.pageSource must contain("Logout")

    }

  }

}
3

3 Answers

4
votes

The issue in my case was the selenium version. Adding this line to appDependencies in Build.scala will upgrade selenium:

"org.seleniumhq.selenium" % "selenium-java" % "2.35.0" % "test"

From there I was able to use both HTMLUNIT and FIREFOX for web drivers without any issues.

0
votes

Have you tried setting a port such as 3333 then using your localhost?

browser.goTo("http://localhost:3333/")
0
votes

Have you solved this? I have the same problem, it also hangs with simple route(FakeRequest) if there is any db connection.

I solved this by setting (Build.scala) : .settings( parallelExecution in Test := false)

It helped me with FakeRequest, but selenium tests still hang.