Skip to content

Instantly share code, notes, and snippets.

@Rubentxu
Forked from eriwen/test.gradle
Created January 18, 2018 17:10
Show Gist options
  • Save Rubentxu/3138e8abd15ec233d211ba50f3d846a9 to your computer and use it in GitHub Desktop.
Save Rubentxu/3138e8abd15ec233d211ba50f3d846a9 to your computer and use it in GitHub Desktop.
Separating tests from integration tests with Gradle
// Usage: gradlew [-Dtest.type=all|unit|integration] test
test {
String testType = System.properties['test.type']
if (testType == 'integration') {
include '**/*IntegrationTest.*'
include '**/*IntegrationSpec.*'
} else if (testType == 'unit') {
include '**/*Test.*'
include '**/*Spec.*'
exclude '**/*IntegrationTest.*'
exclude '**/*IntegrationSpec.*'
} else if (testType == 'all') {
include '**/*Test.*'
include '**/*Spec.*'
} else {
//Default to unit
include '**/*Test.*'
include '**/*Spec.*'
exclude '**/*IntegrationTest.*'
exclude '**/*IntegrationSpec.*'
}
}
// Usage: gradlew integrationTest
task integrationTest(type: Test, description: 'Runs the integration tests', group: 'Verification') {
include '**/*IntegrationTest.*'
include '**/*IntegrationSpec.*'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment