Migrate to TestNG Engine for the JUnit Platform in spring-test
Prior to this commit, we had configured separate test tasks for JUnit and TestNG. In addition, we configured a standard `test` task that depended on the `junit` and `testNG` tasks, and we had an additional `aggregateTestReports` task that aggregated the reports from the JUnit and TestNG test tasks. Thanks to the introduction of the "TestNG Engine for the JUnit Platform", this commit simplifies our Gradle build in the spring-test module by running JUnit 4, JUnit Jupiter, and TestNG tests on the JUnit Platform in a single Gradle `test` task. See gh-27406
This commit is contained in:
parent
a50537fbaf
commit
0b552a3534
|
@ -188,6 +188,7 @@ configure(allprojects) { project ->
|
|||
exclude group: "junit", name: "junit"
|
||||
}
|
||||
dependency "org.testng:testng:7.4.0"
|
||||
dependency "org.junit.support:testng-engine:1.0.1"
|
||||
dependency "org.hamcrest:hamcrest:2.1"
|
||||
dependency "org.awaitility:awaitility:3.1.6"
|
||||
dependency "org.assertj:assertj-core:3.20.2"
|
||||
|
|
|
@ -77,43 +77,23 @@ dependencies {
|
|||
testRuntimeOnly("org.junit.vintage:junit-vintage-engine") {
|
||||
exclude group: "junit", module: "junit"
|
||||
}
|
||||
testRuntimeOnly("org.junit.support:testng-engine")
|
||||
testRuntimeOnly("org.glassfish:javax.el")
|
||||
testRuntimeOnly("com.sun.xml.bind:jaxb-core")
|
||||
testRuntimeOnly("com.sun.xml.bind:jaxb-impl")
|
||||
}
|
||||
|
||||
task junit(type: Test) {
|
||||
description = "Runs JUnit 4 and JUnit Jupiter tests."
|
||||
test {
|
||||
description = "Runs JUnit 4, JUnit Jupiter, and TestNG tests."
|
||||
useJUnitPlatform {
|
||||
includeEngines "junit-vintage", "junit-jupiter", "testng"
|
||||
excludeTags "failing-test-case"
|
||||
}
|
||||
// We use `include` instead of `filter.includeTestsMatching`, since
|
||||
// the latter results in some tests being executed/reported
|
||||
// multiple times.
|
||||
include(["**/*Tests.class", "**/*Test.class"])
|
||||
exclude(["**/testng/**/*.*"])
|
||||
systemProperty("testGroups", project.properties.get("testGroups"))
|
||||
// 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()
|
||||
include(["**/testng/**/*Tests.class", "**/testng/**/*Test.class"])
|
||||
systemProperty("testGroups", project.properties.get("testGroups"))
|
||||
// Show STD_OUT & STD_ERR of the test JVM(s) on the console:
|
||||
// testLogging.showStandardStreams = true
|
||||
// forkEvery 1
|
||||
}
|
||||
|
||||
test {
|
||||
description = "Runs all tests."
|
||||
dependsOn junit, testNG
|
||||
exclude(["**/*.*"])
|
||||
}
|
||||
|
||||
task aggregateTestReports(type: TestReport) {
|
||||
description = "Aggregates JUnit and TestNG test reports."
|
||||
destinationDir = test.reports.html.outputLocation.get().getAsFile()
|
||||
reportOn junit, testNG
|
||||
}
|
||||
|
||||
check.dependsOn aggregateTestReports
|
||||
|
|
Loading…
Reference in New Issue