Browse Source

Ensure aggregateTestReports task is UP-TO-DATE

Prior to this commit, the standard Gradle `test` task was configured to
execute all JUnit tests and had a dependency on the `testNG` task. In
addition, the `aggregateTestReports` task depended on the results of
the `test` and `testNG` tasks as input. Consequently, a subsequent
execution of the `aggregateTestReports` task would not be considered
UP-TO-DATE since the JUnit and TestNG results were both written to the
same "test" reports folder.

This commit introduces a new `junit` test task that allows JUnit and
TestNG test output to be completely independent. The standard `test`
task now depends on `junit` and `testNG` but does not execute any tests
itself, and the `aggregateTestReports` task now depends on the
individual `junit` and `testNG` results instead of on the mixed `test`
results.

See also: eec183ef28
pull/23329/head
Sam Brannen 7 years ago
parent
commit
69214429df
  1. 25
      spring-test/spring-test.gradle

25
spring-test/spring-test.gradle

@ -85,6 +85,17 @@ dependencies {
testRuntime("com.sun.xml.bind:jaxb-impl:2.3.0.1") testRuntime("com.sun.xml.bind:jaxb-impl:2.3.0.1")
} }
task junit(type: Test) {
description = "Runs JUnit 4 and JUnit Jupiter tests."
useJUnitPlatform {
excludeTags "failing-test-case"
}
include(["**/*Tests.class", "**/*Test.class"])
exclude(["**/testng/**/*.*"])
// Java Util Logging for the JUnit Platform.
// systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")
}
task testNG(type: Test) { task testNG(type: Test) {
description = "Runs TestNG tests." description = "Runs TestNG tests."
useTestNG() useTestNG()
@ -96,21 +107,15 @@ task testNG(type: Test) {
} }
test { test {
description = "Runs JUnit 4 and JUnit Jupiter tests." description = "Runs all tests."
dependsOn testNG dependsOn junit, testNG
useJUnitPlatform { exclude(["**/*.*"])
excludeTags "failing-test-case"
}
include(["**/*Tests.class", "**/*Test.class"])
exclude(["**/testng/**/*.*"])
// Java Util Logging for the JUnit Platform.
// systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")
} }
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, testNG reportOn junit, testNG
} }
check.dependsOn aggregateTestReports check.dependsOn aggregateTestReports

Loading…
Cancel
Save