Created
September 1, 2011 21:53
-
-
Save ericr3r/1187393 to your computer and use it in GitHub Desktop.
Web plugin to start Jetty before running Integration Tests
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
seq(WebIntegrationTests.testSettings :_*) | |
seq(webSettings :_*) |
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 sbt._ | |
import Keys._ | |
import WebIntegrationTests._ | |
// project/plugin/WebTestProject | |
object WebTestProject extends Build | |
{ | |
lazy val root = | |
Project("root", file(".")) | |
.configs( WebTest ) | |
.settings( inConfig(WebTest)(Defaults.testSettings) : _*) | |
.settings( libraryDependencies += scalatest ) | |
lazy val scalatest = "org.scalatest" % "scalatest_2.9.0" % "1.6.1" % "webtest,test" | |
} |
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 sbt._ | |
import Keys._ | |
import com.github.siasia.WebPlugin | |
import WebPlugin._ | |
// project/plugin/WebIntegrationTests | |
object WebIntegrationTests extends Plugin { | |
lazy val WebTest = config("webtest") extend(Test) | |
var state : Option[State] = None | |
lazy val testSettings: Seq[Project.Setting[_]] = WebPlugin.webSettings ++ | |
inConfig(WebTest) (Defaults.testSettings) ++ | |
Seq ( | |
prepareWebapp <<= (prepareWebapp in Compile).identity, | |
temporaryWarPath <<= (temporaryWarPath in Compile).identity, | |
webappResources <<= (webappResources in Compile).identity, | |
TaskKey[Unit]("test") in WebTest <<= (TaskKey[Unit]("test") in WebTest).dependsOn(prepareWebapp in Compile), | |
onLoad in Global <<= (onLoad in Global) ?? identity[State], | |
{ | |
val f = (s: State) => { | |
state = Some(s) | |
s | |
} | |
onLoad in Global ~= (f compose _) | |
}, | |
testOptions in WebTest ++= Seq( | |
Tests.Setup { () => | |
if (state.isDefined) { | |
state = Some(jettyRunAction(state.get)) | |
} | |
}, | |
Tests.Cleanup { () => | |
if (state.isDefined) { | |
state = Some(withJettyInstance(_.stop())(state.get)) | |
} | |
} | |
), | |
parallelExecution in WebTest := false | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Quick plugin that I created for my project to allow the existing web plugin to be used to start jetty before integration tests are run and stop jetty after they have been completed