This is an automated email from the ASF dual-hosted git repository.

olamy pushed a commit to branch test-junit-platform-runner-junit4
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


The following commit(s) were added to 
refs/heads/test-junit-platform-runner-junit4 by this push:
     new e2ae23686 testng threadcount fix IT
e2ae23686 is described below

commit e2ae2368627b0050649c6692987173d30c9a2bb6
Author: Olivier Lamy <[email protected]>
AuthorDate: Thu Nov 13 21:13:47 2025 +1000

    testng threadcount fix IT
    
    Signed-off-by: Olivier Lamy <[email protected]>
---
 ...ire1967CheckTestNgMethodParallelOrderingIT.java | 22 ------------------
 .../test/java/testng/parallelOrdering/Base.java    | 26 +++++++++++++---------
 .../junitplatform/JUnitPlatformProvider.java       | 19 ++++++++--------
 3 files changed, 25 insertions(+), 42 deletions(-)

diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1967CheckTestNgMethodParallelOrderingIT.java
 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1967CheckTestNgMethodParallelOrderingIT.java
index 555127cdb..c403bf0b5 100644
--- 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1967CheckTestNgMethodParallelOrderingIT.java
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1967CheckTestNgMethodParallelOrderingIT.java
@@ -34,26 +34,4 @@ public void testNgParallelOrdering() {
                 .executeTest()
                 .verifyErrorFree(12);
     }
-
-    // Since the test ordering guarantees currently depend on reflection, it's 
useful to test with
-    // some older version too.
-    @Test
-    public void testNgParallelOrderingWithVersion6() {
-        unpack("surefire-1967-testng-method-parallel-ordering")
-                .sysProp("testNgVersion", "6.10")
-                .executeTest()
-                .verifyErrorFree(12);
-    }
-
-    // TestNG 6.2.1 is the newest version that doesn't have XmlClass.setIndex 
method yet.
-    // Note that the problem of wrong setup methods ordering (SUREFIRE-1967) 
was not observed on that version.
-    // This is likely because SUREFIRE-1967 is related to a change in TestNG 
6.3, where preserve-order became true by
-    // default 
(https://github.com/cbeust/testng/commit/8849b3406ef2184ceb6002768a2d087d7a8de8d5).
-    @Test
-    public void testNgParallelOrderingWithEarlyVersion6() {
-        unpack("surefire-1967-testng-method-parallel-ordering")
-                .sysProp("testNgVersion", "6.2.1")
-                .executeTest()
-                .verifyErrorFree(12);
-    }
 }
diff --git 
a/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/Base.java
 
b/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/Base.java
index ab37f14c7..87eeccd5f 100644
--- 
a/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/Base.java
+++ 
b/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/Base.java
@@ -1,7 +1,9 @@
 package testng.parallelOrdering;
 
 import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import java.util.concurrent.ThreadLocalRandom;
@@ -12,47 +14,49 @@ public abstract class Base
     private static final AtomicInteger resources = new AtomicInteger();
 
     // This simulates resource allocation
-    @BeforeClass
+    @BeforeMethod
     public void setupAllocateResources()
     {
         int concurrentResources = resources.incrementAndGet();
+        System.out.println("setupAllocateResources: " + concurrentResources);
         if (concurrentResources > 2) {
             throw new IllegalStateException("Tests execute in two threads, so 
there should be at most 2 resources allocated, got: " + concurrentResources);
         }
     }
 
     // This simulates freeing resources
-    @AfterClass(alwaysRun = true)
+    @AfterMethod(alwaysRun = true)
     public void tearDownReleaseResources()
     {
-        resources.decrementAndGet();
+        System.out.println("tearDownReleaseResources: "  + 
resources.decrementAndGet());
     }
 
     @Test
     public void test1()
-            throws Exception
+        throws Exception
     {
-        sleepShortly();
+        sleepShortly("test1");
     }
 
     @Test
     public void test2()
-            throws Exception
+        throws Exception
     {
-        sleepShortly();
+        sleepShortly("test2");
     }
 
     @Test
     public void test3()
-            throws Exception
+        throws Exception
     {
-        sleepShortly();
+        sleepShortly("test3");
     }
 
     // Sleep random time to let tests interleave. Keep sleep short not to 
extend tests duration too much.
-    private void sleepShortly()
-            throws InterruptedException
+    private void sleepShortly(String method)
+        throws InterruptedException
     {
+        System.out.println("Sleep shortly:" + method + ", " + 
Thread.currentThread().getName() + " " + getClass().getSimpleName());
         Thread.sleep(ThreadLocalRandom.current().nextInt(3));
     }
 }
diff --git 
a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java
 
b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java
index 45ca9d50a..39152daf6 100644
--- 
a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java
+++ 
b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java
@@ -117,33 +117,34 @@ public JUnitPlatformProvider(ProviderParameters 
parameters) {
         filters = newFilters();
         parameters.getProviderProperties().entrySet().stream()
                 .filter(entry -> 
entry.getKey().startsWith("junit.vintage.execution.parallel"))
-                .forEach(entry -> configurationParameters.put(entry.getKey(), 
entry.getValue()));
-        configurationParameters.putAll(newConfigurationParameters());
+                .forEach(entry -> 
getConfigurationParameters().put(entry.getKey(), entry.getValue()));
+        getConfigurationParameters().putAll(newConfigurationParameters());
 
         // don't start a thread in CommandReader while we are in in-plugin 
process
         commandsReader = parameters.isInsideFork() ? 
parameters.getCommandReader() : null;
 
         parameters.getProviderProperties().entrySet().stream()
                 .filter(entry -> entry.getKey().startsWith("testng."))
-                .forEach(entry -> configurationParameters.put(entry.getKey(), 
entry.getValue()));
+                .forEach(entry -> 
getConfigurationParameters().put(entry.getKey(), entry.getValue()));
         // testng compatibility parameters
         String groups = parameters.getProviderProperties().get(GROUPS_PROP);
         if (groups != null) {
-            configurationParameters.put("testng.groups", groups);
+            getConfigurationParameters().put("testng.groups", groups);
         }
 
         //        configurationParameters.put("testng.useDefaultListeners", 
"true");
 
         Optional.ofNullable(parameters.getProviderProperties().get("listener"))
-                .ifPresent(listener -> 
configurationParameters.put("testng.listeners", listener));
+                .ifPresent(listener -> 
getConfigurationParameters().put("testng.listeners", listener));
 
         Optional.ofNullable(parameters.getProviderProperties().get("reporter"))
-                .ifPresent(reporter -> configurationParameters.compute(
-                        "testng.listeners", (key, value) -> value == null ? 
reporter : value + "," + reporter));
+                .ifPresent(reporter -> getConfigurationParameters()
+                        .compute(
+                                "testng.listeners", (key, value) -> value == 
null ? reporter : value + "," + reporter));
 
         String excludeGroups = 
parameters.getProviderProperties().get(EXCLUDEDGROUPS_PROP);
         if (excludeGroups != null) {
-            configurationParameters.put("testng.excludedGroups", 
excludeGroups);
+            getConfigurationParameters().put("testng.excludedGroups", 
excludeGroups);
         }
     }
 
@@ -278,7 +279,7 @@ private LauncherDiscoveryRequest 
buildLauncherDiscoveryRequestForRerunFailures(R
     }
 
     private LauncherDiscoveryRequestBuilder newRequest() {
-        return 
request().filters(filters).configurationParameters(configurationParameters);
+        return 
request().filters(filters).configurationParameters(getConfigurationParameters());
     }
 
     private boolean matchClassName(String className, String pattern) {

Reply via email to