OnJava8-Examples/gradle/junit-jupiter.gradle
Bruce Eckel 2ab352d970 Revert "Trying to upgrade build parts"
This reverts commit 0b9d0341fea1d855915be7c87372e844f264d86e.
2020-10-05 13:08:25 -06:00

63 lines
1.6 KiB
Groovy

import org.apache.tools.ant.util.TeeOutputStream
apply plugin: 'org.junit.platform.gradle.plugin'
ext {
junitJupiterVersion = '5.0.0-M2'
}
dependencies {
testCompile "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}"
testRuntime "org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}"
}
junitPlatform {
platformVersion '1.0.0-M2'
includeClassNamePattern '.*'
}
/* NEW: (REQUIRES CODE REWRITES IN BOOK AND TEST CODE)
-> http://junit.org/junit5/docs/current/user-guide/
ext {
junitJupiterVersion = '5.0.0-M3'
}
dependencies {
testCompile "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}"
testRuntime "org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}"
}
junitPlatform {
platformVersion '1.0.0-M3'
filters {
packages {
exclude 'collectiontopics.jmh'
}
includeClassNamePattern '.*'
}
}
*/
/* Store test output in $projectName/tests
JUnit 5's junitPlatformTest runs as a "javaExec" rather than a "test",
so we can't hook into the before/after test behavior.
*/
tasks.findByPath(":$name:junitPlatformTest").configure {
File testDir = file("tests")
if(testDir.exists()) {
File outFile = new File(testDir, 'report.txt')
doFirst {
standardOutput = new TeeOutputStream(new FileOutputStream(outFile, true), System.out)
}
doLast {
if(outFile.size() == 0)
outFile.delete()
else if(outFile.text.contains("0 tests found"))
outFile.delete()
}
}
}