Skip to content

Instantly share code, notes, and snippets.

@ttddyy
Created March 3, 2012 22:24
Show Gist options
  • Save ttddyy/1968643 to your computer and use it in GitHub Desktop.
Save ttddyy/1968643 to your computer and use it in GitHub Desktop.
run multiple jetty before tests in gradle
// start multiple jetties before test
//
// useful for parallel web end-to-end testing
//
import org.gradle.api.plugins.jetty.JettyRun
apply plugin: 'java'
apply plugin: 'jetty'
repositories {
mavenCentral()
}
// configuration for each jetty server
def jettyConfigs = [
[port:8001],
[port:8002]
]
def jettyMultiRunTasks = []
// create jetty tasks and assign them
jettyConfigs.eachWithIndex {jettyConfig, index ->
jettyMultiRunTasks << task("jettyMultiRun-${index}", type: JettyRun) {
httpPort = jettyConfig.port
daemon = true
// more configuration to specify each jetty to use different env...
}
}
test {
// start jetties before running tests
dependsOn(jettyMultiRunTasks)
// more test options such as maxParallelForks, etc.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment