From 69214429df2ec644da6eb121edf6e323ee16eaea Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 21 Jul 2019 17:21:24 +0200 Subject: [PATCH] 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: eec183ef2840d0e3cc20af01f69cda1adea7383e --- spring-test/spring-test.gradle | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/spring-test/spring-test.gradle b/spring-test/spring-test.gradle index f76d6b93c61..c5c45db98b0 100644 --- a/spring-test/spring-test.gradle +++ b/spring-test/spring-test.gradle @@ -85,6 +85,17 @@ dependencies { 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) { description = "Runs TestNG tests." useTestNG() @@ -96,21 +107,15 @@ task testNG(type: Test) { } test { - description = "Runs JUnit 4 and JUnit Jupiter tests." - dependsOn testNG - 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") + description = "Runs all tests." + dependsOn junit, testNG + exclude(["**/*.*"]) } task aggregateTestReports(type: TestReport) { description = "Aggregates JUnit and TestNG test reports." destinationDir = test.reports.html.destination - reportOn test, testNG + reportOn junit, testNG } check.dependsOn aggregateTestReports