Browse Source

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
pull/23290/head
Sam Brannen 5 years ago
parent
commit
480b1e0a0d
  1. 24
      spring-test/spring-test.gradle

24
spring-test/spring-test.gradle

@ -80,7 +80,7 @@ dependencies {
testCompile("io.projectreactor.netty:reactor-netty") testCompile("io.projectreactor.netty:reactor-netty")
testCompile("de.bechte.junit:junit-hierarchicalcontextrunner:4.12.1") testCompile("de.bechte.junit:junit-hierarchicalcontextrunner:4.12.1")
// Pull in the latest JUnit 5 Launcher API and the Vintage engine as well // 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.jupiter:junit-jupiter-engine")
testRuntime("org.junit.platform:junit-platform-launcher") testRuntime("org.junit.platform:junit-platform-launcher")
testRuntime("org.junit.vintage:junit-vintage-engine") testRuntime("org.junit.vintage:junit-vintage-engine")
@ -99,32 +99,22 @@ task testNG(type: Test) {
// forkEvery 1 // forkEvery 1
} }
task testJUnitJupiter(type: Test) { test {
description = "Runs JUnit Jupiter tests." description = "Runs JUnit 4 and JUnit Jupiter tests."
dependsOn testNG
useJUnitPlatform { useJUnitPlatform {
includeEngines "junit-jupiter"
excludeTags "failing-test-case" excludeTags "failing-test-case"
} }
filter { include(["**/*Tests.class", "**/*Test.class"])
includeTestsMatching "org.springframework.test.context.junit.jupiter.*" exclude(["**/testng/**/*.*"])
}
// 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 {
description = "Runs JUnit 4 tests."
dependsOn testJUnitJupiter, testNG
useJUnit()
scanForTestClasses = false
include(["**/*Tests.class", "**/*Test.class"])
exclude(["**/testng/**/*.*", "**/jupiter/**/*.*"])
}
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 test, testNG
} }
check.dependsOn aggregateTestReports check.dependsOn aggregateTestReports

Loading…
Cancel
Save