This is an automated email from the ASF dual-hosted git repository. benw pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tapestry-5.git
commit 2b31a26e2b463a7d0072ad8845f4f4df2b24ffc6 Author: Ben Weidig <[email protected]> AuthorDate: Sun Apr 12 12:45:49 2026 +0200 TAP5-2809: run JUnit4 via vintage engine, add explicit testNG task --- Jenkinsfile | 7 ++++--- .../tapestry.junit4-legacy-convention.gradle | 8 ++------ .../groovy/tapestry.testing-base-convention.gradle | 6 +++--- .../main/groovy/tapestry.testng-convention.gradle | 24 ++++++++++++++-------- gradle/libs.versions.toml | 1 + 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6cd8e7da4..dd10d25e8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -46,10 +46,11 @@ pipeline { sh './gradlew check combinedJacocoReport --continue' } post { - always { - // Prefix the JUnit classnames so the Test UI shows which JDK ran which test + always { + // Prefix the classnames for JUnit and TestNG results sh """ - find . -path '*/build/test-results/test/*.xml' -exec \ + find . -path '*/build/test-results/**/*.xml' \ + -not -path '*/matrix-artifacts/*' -exec \ sed -i 's/classname="/classname="${JDK_VERSION}./g' {} + """ diff --git a/buildSrc/src/main/groovy/tapestry.junit4-legacy-convention.gradle b/buildSrc/src/main/groovy/tapestry.junit4-legacy-convention.gradle index 54b2d6577..ac37c9b3a 100644 --- a/buildSrc/src/main/groovy/tapestry.junit4-legacy-convention.gradle +++ b/buildSrc/src/main/groovy/tapestry.junit4-legacy-convention.gradle @@ -1,11 +1,7 @@ plugins { - id 'tapestry.testing-base-convention' + id 'tapestry.junit5-convention' } dependencies { - testImplementation libs.junit4 -} - -tasks.withType(Test).configureEach { - useJUnit() + testRuntimeOnly libs.junit.vintage.engine } diff --git a/buildSrc/src/main/groovy/tapestry.testing-base-convention.gradle b/buildSrc/src/main/groovy/tapestry.testing-base-convention.gradle index 35dd0f937..53a0648e1 100644 --- a/buildSrc/src/main/groovy/tapestry.testing-base-convention.gradle +++ b/buildSrc/src/main/groovy/tapestry.testing-base-convention.gradle @@ -50,13 +50,13 @@ tasks.withType(Test).configureEach { testTask -> // The root suite has a null parent. We only want to log the final summary. if (descriptor.parent == null) { total = passed + failed + skipped - // Using project.path gives a clear identifier like ":tapestry-core" - def projectName = project.path + // Using project.path plus task gives a clear identifier like ":tapestry-core:test" + def taskIdentifier = "${project.path}:${name}" // Don't log if no tests were run if (total > 0) { logger.lifecycle "------------------------------------------------------------------------" - logger.lifecycle "Test Results for ${projectName}" + logger.lifecycle "Test Results for ${taskIdentifier}" logger.lifecycle " Tests run: ${total}, Passed: ${passed}, Failed: ${failed}, Skipped: ${skipped}" logger.lifecycle "------------------------------------------------------------------------" } diff --git a/buildSrc/src/main/groovy/tapestry.testng-convention.gradle b/buildSrc/src/main/groovy/tapestry.testng-convention.gradle index da6dc9d17..6e2b5ce14 100644 --- a/buildSrc/src/main/groovy/tapestry.testng-convention.gradle +++ b/buildSrc/src/main/groovy/tapestry.testng-convention.gradle @@ -7,20 +7,26 @@ dependencies { testImplementation libs.easymock } -tasks.withType(Test).configureEach { testTask -> +def testNGTask = tasks.register('testNG', Test) { + group = 'verification' + description = 'Runs TESTNG tests.' - def suiteFile = [ + def suiteFiles = [ 'src/test/resources/testng.xml', 'src/test/conf/testng.xml' - ].find { path -> - project.file(path).exists() - } + ].collect { path -> layout.projectDirectory.file(path).asFile } + + def existingSuite = suiteFiles.find { it.exists() } - if (suiteFile) { - testTask.useTestNG { - suites suiteFile + if (existingSuite) { + useTestNG { + suites(existingSuite) } } else { - testTask.useTestNG() + useTestNG() } } + +tasks.named('check') { + dependsOn(testNGTask) +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a818a00d6..1384d14f2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -195,6 +195,7 @@ junit-jupiter = { module = "org.junit.jupiter:junit-jupiter"} junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api" } junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params" } junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine" } +junit-vintage-engine = { module = "org.junit.vintage:junit-vintage-engine" } junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" } junit4 = { module = "junit:junit", version.ref = "junit4" }
