Skip to content

Instantly share code, notes, and snippets.

@AndyBowes
Last active September 26, 2016 10:14
Show Gist options
  • Save AndyBowes/0e4c8b6d778a00a8808d6c6de722d701 to your computer and use it in GitHub Desktop.
Save AndyBowes/0e4c8b6d778a00a8808d6c6de722d701 to your computer and use it in GitHub Desktop.
Gradle - Create Integration Tests
// Assumes 'java', 'groovy' or 'scala' plugins have been applied before
// Add integration test source sets
sourceSets {
integrationTest { sourceSet ->
["java", "groovy", "scala", "resources"].each {
if (!sourceSet.hasProperty(it)) return
sourceSet."$it".srcDir file("src/integration-test/${it}")
}
}
}
// Setup dependencies for integration testing
dependencies {
integrationTestCompile sourceSets.main.output
integrationTestCompile sourceSets.test.output
integrationTestCompile configurations.testCompile
integrationTestRuntime configurations.testRuntime
}
// Define integration test task
task integrationTest(type: Test) {
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = sourceSets.integrationTest.runtimeClasspath
}
// Make sure 'check' task calls integration test
check.dependsOn integrationTest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment