Created
January 3, 2013 14:06
-
-
Save tgpfeiffer/4443698 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.scalatest._ | |
import org.scalatest.time._ | |
import org.scalatest.selenium._ | |
import org.openqa.selenium._ | |
import org.mortbay.jetty.Server | |
import org.mortbay.jetty.webapp.WebAppContext | |
import org.apache.log4j.Logger | |
trait JettySetup extends FlatSpec | |
with BeforeAndAfterAll | |
with Firefox { // <-- THIS LINE can also say "with HtmlUnit" | |
private val runServer = false | |
private var server: Server = null | |
private val GUI_PORT = 8080 | |
protected var host = "http://localhost:" + GUI_PORT.toString | |
override def beforeAll() { | |
Logger.getRootLogger.debug("hello from test") | |
if (runServer) { | |
// Setting up the jetty instance which will be running the | |
// GUI for the duration of the tests | |
server = new Server(GUI_PORT) | |
val context = new WebAppContext() | |
context.setServer(server) | |
context.setContextPath("/") | |
context.setWar("src/main/webapp") | |
server.addHandler(context) | |
server.start() | |
} | |
implicitlyWait(Span(2, Seconds)); | |
} | |
override def afterAll() { | |
// Close everything when done | |
close() | |
if (runServer) { | |
server.stop() | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<dependency> | |
<groupId>org.seleniumhq.selenium</groupId> | |
<artifactId>selenium-java</artifactId> | |
<version>2.25.0</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.scalatest</groupId> | |
<artifactId>scalatest_2.9.1</artifactId> | |
<version>2.0.M4</version> | |
<scope>test</scope> | |
</dependency> | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net.liftweb.util._ | |
import net.liftweb.util.Helpers._ | |
import net.liftweb.common._ | |
import org.scalatest._ | |
import org.scalatest.time._ | |
import org.scalatest.selenium._ | |
import org.openqa.selenium._ | |
import scala.xml._ | |
class M02TestsBrowser extends JettySetup | |
with ShouldMatchers { | |
def basics = { | |
"The home page" should "have the correct title" in { | |
goTo(host) | |
title should be("Home | My Website") | |
} | |
} | |
basics | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment