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 4c32a4be870cab65fce4bc8d45bcacef9111a6b0 Author: Ben Weidig <[email protected]> AuthorDate: Sun Apr 12 16:51:22 2026 +0200 TAP5-2809: register core integration test tasks for both JUnit and TestNG --- .../groovy/tapestry.testing-base-convention.gradle | 1 - .../main/groovy/tapestry.testng-convention.gradle | 2 +- tapestry-core/build.gradle | 77 ++++++++++++++++++---- 3 files changed, 64 insertions(+), 16 deletions(-) diff --git a/buildSrc/src/main/groovy/tapestry.testing-base-convention.gradle b/buildSrc/src/main/groovy/tapestry.testing-base-convention.gradle index 53a0648e1..7a105f7e2 100644 --- a/buildSrc/src/main/groovy/tapestry.testing-base-convention.gradle +++ b/buildSrc/src/main/groovy/tapestry.testing-base-convention.gradle @@ -63,4 +63,3 @@ tasks.withType(Test).configureEach { testTask -> } } } - diff --git a/buildSrc/src/main/groovy/tapestry.testng-convention.gradle b/buildSrc/src/main/groovy/tapestry.testng-convention.gradle index 6e2b5ce14..9ca8e29ac 100644 --- a/buildSrc/src/main/groovy/tapestry.testng-convention.gradle +++ b/buildSrc/src/main/groovy/tapestry.testng-convention.gradle @@ -9,7 +9,7 @@ dependencies { def testNGTask = tasks.register('testNG', Test) { group = 'verification' - description = 'Runs TESTNG tests.' + description = 'Runs TetstNG tests.' def suiteFiles = [ 'src/test/resources/testng.xml', diff --git a/tapestry-core/build.gradle b/tapestry-core/build.gradle index d50636592..06cd89d35 100644 --- a/tapestry-core/build.gradle +++ b/tapestry-core/build.gradle @@ -1,10 +1,13 @@ +import org.gradle.api.tasks.testing.Test +import t5build.TapestryBuildLogic +import org.apache.tools.ant.filters.ReplaceTokens + plugins { + id 'tapestry.testing-base-convention' id 'tapestry.junit5-convention' id 'tapestry.testng-convention' } -import t5build.TapestryBuildLogic -import org.apache.tools.ant.filters.ReplaceTokens description = 'Central module for Tapestry, containing all core services and components' @@ -138,12 +141,64 @@ test { } // Default is jQuery and Require.js enabled, so here are the tests for the -// other combinations +// other combinations. +// Tests need to run both JUnit and TestNG, so we need to register both +// and connect them all. + +def registerTestPair(String baseName, Closure configuration) { + + // Logic to configure a task with the user-provided closure + def configureTask = { Test task -> + // Create a copy of the closure to avoid side effects + Closure configClone = configuration.clone() + configClone.delegate = task + configClone.resolveStrategy = Closure.DELEGATE_FIRST + configClone.call() + } + + def jUnit = tasks.register("${baseName}JUnit", Test) { + group = 'verification' + description = "Runs JUnit tests for ${baseName}" + + useJUnitPlatform() + + binaryResultsDirectory = layout.buildDirectory.dir("test-results/$name") + reports.html.outputLocation = layout.buildDirectory.dir("reports/tests/$name") + + configureTask(it) + } -tasks.register('testWithJqueryAndRequireJsDisabled', Test) { - group = 'Verification' - description = 'Runs tests with jQuery and Require.js disabled' + def testNG = tasks.register("${baseName}TestNG", Test) { + group = 'verification' + description = "Rest TestNG tests for ${baseName}" + // Logic to find TestNG suite file + def suiteFile = [ + 'src/test/resources/testng.xml', + 'src/test/conf/testng.xml' + ].collect { layout.projectDirectory.file(it).asFile }.find { it.exists() } + + useTestNG { + if (suiteFile) { + suites(suiteFile) + } + } + + binaryResultsDirectory = layout.buildDirectory.dir("test-results/$name") + reports.html.outputLocation = layout.buildDirectory.dir("reports/tests/$name") + + configureTask(it) + } + + tasks.register(baseName) { + group = 'verification' + description = "Runs JUnit and TestNG tests for ${baseName}" + + dependsOn jUnit, testNG + } +} + +registerTestPair('testWithJqueryAndRequireJsDisabled') { systemProperties( 'tapestry.javascript-infrastructure-provider': 'jquery', 'tapestry.require-js-enabled': 'false', @@ -152,10 +207,7 @@ tasks.register('testWithJqueryAndRequireJsDisabled', Test) { ) } -tasks.register('testWithPrototypeAndRequireJsEnabled', Test) { - group = 'Verification' - description = 'Runs tests with Prototype and Require.js enabled' - +registerTestPair('testWithPrototypeAndRequireJsEnabled') { systemProperties( 'tapestry.javascript-infrastructure-provider': 'prototype', 'tapestry.require-js-enabled': 'true', @@ -164,10 +216,7 @@ tasks.register('testWithPrototypeAndRequireJsEnabled', Test) { ) } -tasks.register('testWithPrototypeAndRequireJsDisabled', Test) { - group = 'Verification' - description = 'Runs tests with Prototype and Require.js disabled' - +registerTestPair('testWithPrototypeAndRequireJsDisabled') { systemProperties( 'tapestry.javascript-infrastructure-provider': 'prototype', 'tapestry.require-js-enabled': 'false',
