Zero configuration, single responsibility gradle plugin for integration tests.
- Adds
integrationTest
task that executes tests undersrc/integration/*
. - Adds
testAll
task that executes tests undersrc/test/*
andsrc/integration/*
. - Handles runtime flags parameters to skip tests:
skipTests
,skipIntegrationTests
,skipUnitTests
. - Makes integration classpath extend test classpath and main classpath (in this order).
- Configures
idea
plugin to treat integration source dirs as test dirs (only whenidea
plugin is enabled or there is.idea
folder in project root directory).
Add to your build.gradle
:
plugins {
id "com.coditory.integration-test" version "1.2.3"
}
See a project with all the examples.
Java + JUnit4 (project)
plugins {
id "java"
id "com.coditory.integration-test" version "1.2.3"
}
dependencies {
testCompile "junit:junit:4.12"
}
Java + JUnit5 (project)
plugins {
id "java"
id "com.coditory.integration-test" version "1.2.3"
}
dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
testRuntime "org.junit.jupiter:junit-jupiter-engine:5.6.2"
}
tasks.withType(Test) {
useJUnitPlatform()
}
Groovy + Spock (project)
plugins {
id "groovy"
id "com.coditory.integration-test" version "1.2.3"
}
dependencies {
testCompile "org.spockframework:spock-core:2.0-M2-groovy-3.0"
}
tasks.withType(Test) {
useJUnitPlatform()
}
Kotlin + JUnit5 (project)
plugins {
kotlin("jvm") version "1.3.70"
id("com.coditory.integration-test") version "1.2.3"
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.1")
}
tasks.withType<Test> {
useJUnitPlatform()
}
Running tests:
# Runs tests from /src/test
./gradlew test
# Runs tests /src/integration
./gradlew integrationTest
./gradlew iT
# Runs all tests (/src/test and /src/integration)
./gradlew testAll
./gradlew tA
Skipping tests:
# Skip all tests
./gradlew clean build -x test integrationTest
# ...or skipTests=true/false
./gradlew clean build -PskipTests
# Skip tests from /src/test
./gradlew clean build -x test
# ...or skipUnitTests=true/false
./gradlew clean build -PskipUnitTests
# Skip tests from /src/integration
./gradlew clean build -x integrationTest
# ...or skipIntegrationTests=true/false
./gradlew clean build -PskipIntegrationTests
Test filtering is supported as well:
./gradlew iT --tests com.coditory.SampleTest.shouldWork
Creating a single Jacoco report for unit and integration tests:
jacocoTestReport {
executionData(fileTree(project.buildDir).include("jacoco/*.exec"))
reports {
xml.enabled = true
html.enabled = true
}
}