Gradle JUnit5 ( ). . , : , , maven test vs. verify.
() .
Gradle main test source , . Integration, . , , Set, , ( ". IntegrationTest" Set IntegrationTest sourceSet). , .
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integrationTest/java')
}
resources.srcDir file('src/integrationTest/resources')
}
}
java, integrationTestCompile integrationTestRuntime dependencies:
dependencies {
testCompile "org.assertj:assertj-core:${assertjVersion}"
integrationTestCompile("org.springframework.boot:spring-boot-starter-test") {
exclude module: 'junit:junit'
}
}
!
, . , ; , .
def integrationTest = task('integrationTest',
type: JavaExec,
group: 'Verification') {
description = 'Runs integration tests.'
dependsOn testClasses
shouldRunAfter test
classpath = sourceSets.integrationTest.runtimeClasspath
main = 'org.junit.platform.console.ConsoleLauncher'
args = ['--scan-class-path',
sourceSets.integrationTest.output.classesDir.absolutePath,
'--reports-dir', "${buildDir}/test-results/junit-integrationTest"]
}
dependOn shouldRunAfter, , . , , ./gradlew check, :
check {
dependsOn integrationTest
}
./gradlew test ./mvnw test ./gradlew check ./mvnw verify.