Ensure spring-test test tasks are UP-TO-DATE

See also: 69214429df and eec183ef28
This commit is contained in:
Sam Brannen 2019-09-05 15:06:12 +02:00
parent d036b5a283
commit a7aecbb4dc
2 changed files with 23 additions and 19 deletions

View File

@ -139,7 +139,6 @@ configure(allprojects) { project ->
// classes with the "$" pattern; otherwise, using -Dtest.single=MyTests to // classes with the "$" pattern; otherwise, using -Dtest.single=MyTests to
// run MyTests by itself will fail if MyTests contains any inner classes. // run MyTests by itself will fail if MyTests contains any inner classes.
exclude(["**/Abstract*.class", '**/*$*']) exclude(["**/Abstract*.class", '**/*$*'])
reports.junitXml.setDestination(file("$buildDir/test-results"))
} }
checkstyle { checkstyle {

View File

@ -87,18 +87,16 @@ dependencies {
testRuntime("com.sun.xml.bind:jaxb-impl:2.3.0.1") testRuntime("com.sun.xml.bind:jaxb-impl:2.3.0.1")
} }
task testNG(type: Test) { task junit4(type: Test) {
description = "Runs TestNG tests." description = "Runs JUnit 4 tests."
useTestNG() useJUnit()
systemProperty("testGroups", project.properties.get("testGroups"))
scanForTestClasses = false scanForTestClasses = false
include(["**/testng/**/*Tests.class", "**/testng/**/*Test.class"]) include(["**/*Tests.class", "**/*Test.class"])
// Show STD_OUT & STD_ERR of the test JVM(s) on the console: exclude(["**/Abstract*.class", "**/testng/**/*.*", "**/jupiter/**/*.*"])
// testLogging.showStandardStreams = true
// forkEvery 1
reports.junitXml.destination = file("$buildDir/test-results")
} }
task testJUnitJupiter(type: Test) { task junitJupiter(type: Test) {
description = "Runs JUnit Jupiter tests." description = "Runs JUnit Jupiter tests."
useJUnitPlatform { useJUnitPlatform {
includeEngines "junit-jupiter" includeEngines "junit-jupiter"
@ -107,25 +105,32 @@ task testJUnitJupiter(type: Test) {
filter { filter {
includeTestsMatching "org.springframework.test.context.junit.jupiter.*" includeTestsMatching "org.springframework.test.context.junit.jupiter.*"
} }
reports.junitXml.destination = file("$buildDir/test-results") systemProperty("testGroups", project.properties.get("testGroups"))
// Java Util Logging for the JUnit Platform. // Java Util Logging for the JUnit Platform.
// systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager") // systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")
} }
test { task testNG(type: Test) {
description = "Runs JUnit 4 tests." description = "Runs TestNG tests."
dependsOn testJUnitJupiter, testNG useTestNG()
useJUnit() systemProperty("testGroups", project.properties.get("testGroups"))
scanForTestClasses = false scanForTestClasses = false
include(["**/*Tests.class", "**/*Test.class"]) include(["**/testng/**/*Tests.class", "**/testng/**/*Test.class"])
exclude(["**/testng/**/*.*", "**/jupiter/**/*.*"]) // Show STD_OUT & STD_ERR of the test JVM(s) on the console:
reports.junitXml.destination = file("$buildDir/test-results") // testLogging.showStandardStreams = true
// forkEvery 1
}
test {
description = "Runs all tests."
dependsOn junit4, junitJupiter, testNG
exclude(["**/*.*"])
} }
task aggregateTestReports(type: TestReport) { task aggregateTestReports(type: TestReport) {
description = "Aggregates JUnit and TestNG test reports." description = "Aggregates JUnit and TestNG test reports."
destinationDir = test.reports.html.destination destinationDir = test.reports.html.destination
reportOn test, testJUnitJupiter, testNG reportOn junit4, junitJupiter, testNG
} }
check.dependsOn aggregateTestReports check.dependsOn aggregateTestReports