From 480b1e0a0d7fa2192c4209a572763114f8941ccd Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 13 Jul 2019 18:24:37 +0200 Subject: [PATCH] Run JUnit 4 tests in spring-test on the JUnit Platform This commit simplifies the build for spring-test by running JUnit 4 tests and JUnit Jupiter tests together in the standard Gradle `test` task. As an added bonus, the ignored tests in SpringJUnit4ConcurrencyTests and ClassLevelDisabledSpringRuleTests are now reported in the test results. See gh-23286 --- spring-test/spring-test.gradle | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/spring-test/spring-test.gradle b/spring-test/spring-test.gradle index d1e81279ba..58bcfefef7 100644 --- a/spring-test/spring-test.gradle +++ b/spring-test/spring-test.gradle @@ -80,7 +80,7 @@ dependencies { testCompile("io.projectreactor.netty:reactor-netty") testCompile("de.bechte.junit:junit-hierarchicalcontextrunner:4.12.1") // Pull in the latest JUnit 5 Launcher API and the Vintage engine as well - // so that we can run JUnit 4 tests in IntelliJ IDEA. + // so that we can run JUnit 4 tests in IDEs. testRuntime("org.junit.jupiter:junit-jupiter-engine") testRuntime("org.junit.platform:junit-platform-launcher") testRuntime("org.junit.vintage:junit-vintage-engine") @@ -99,32 +99,22 @@ task testNG(type: Test) { // forkEvery 1 } -task testJUnitJupiter(type: Test) { - description = "Runs JUnit Jupiter tests." +test { + description = "Runs JUnit 4 and JUnit Jupiter tests." + dependsOn testNG useJUnitPlatform { - includeEngines "junit-jupiter" excludeTags "failing-test-case" } - filter { - includeTestsMatching "org.springframework.test.context.junit.jupiter.*" - } + 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") } -test { - description = "Runs JUnit 4 tests." - dependsOn testJUnitJupiter, testNG - useJUnit() - scanForTestClasses = false - include(["**/*Tests.class", "**/*Test.class"]) - exclude(["**/testng/**/*.*", "**/jupiter/**/*.*"]) -} - task aggregateTestReports(type: TestReport) { description = "Aggregates JUnit and TestNG test reports." destinationDir = test.reports.html.destination - reportOn test, testJUnitJupiter, testNG + reportOn test, testNG } check.dependsOn aggregateTestReports