Last active
September 26, 2016 10:14
-
-
Save AndyBowes/0e4c8b6d778a00a8808d6c6de722d701 to your computer and use it in GitHub Desktop.
Gradle - Create Integration Tests
This file contains hidden or 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
// 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