Skip to content

Instantly share code, notes, and snippets.

@sjednac
Created May 28, 2015 22:32
Show Gist options
  • Save sjednac/6fe3b87dec76f06a2593 to your computer and use it in GitHub Desktop.
Save sjednac/6fe3b87dec76f06a2593 to your computer and use it in GitHub Desktop.
A Selenium test run with ScalaTest on a Spring Boot application.
import org.junit.runner.RunWith
import org.scalatest.selenium.HtmlUnit
import org.scalatest.{FlatSpec, ShouldMatchers}
import org.springframework.boot.test.{SpringApplicationConfiguration, WebIntegrationTest}
import org.springframework.test.context.TestContextManager
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
@RunWith(classOf[SpringJUnit4ClassRunner])
@SpringApplicationConfiguration(classes = Array(classOf[Application]))
@WebIntegrationTest(value = Array("server.port=9000"))
class SpringAndSeleniumScalaTest extends FlatSpec with ShouldMatchers with HtmlUnit {
val host = "http://localhost:9000/"
//Required for Spring integration (http://stackoverflow.com/a/6282908/1535738)
new TestContextManager(this.getClass()).prepareTestInstance(this)
"User" should "be able to visit the home page" in {
go to (host)
pageTitle should be("Some title")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment