olamy commented on code in PR #3212:
URL: https://github.com/apache/maven-surefire/pull/3212#discussion_r2520219052


##########
surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java:
##########
@@ -224,29 +221,51 @@ private void invokeAllTests(LauncherAdapter launcher, 
TestsToRun testsToRun, Run
     }
 
     private void execute(LauncherAdapter launcher, TestsToRun testsToRun, 
RunListenerAdapter adapter) {
-        // parameters.getProviderProperties().get(CONFIGURATION_PARAMETERS)
-        // add this LegacyXmlReportGeneratingListener ?
-        //            adapter,
-        //            new LegacyXmlReportGeneratingListener(
-        //                    new File("target", "junit-platform").toPath(), 
new PrintWriter(System.out))
-        //        };
+        List<TestExecutionListener> testExecutionListeners = new ArrayList<>();
+        testExecutionListeners.add(adapter);
 
-        TestExecutionListener[] testExecutionListeners = new 
TestExecutionListener[] {adapter};
+        TestExecutionListener customListeners = createCustomListener();
+        if (customListeners != null) {
+            testExecutionListeners.add(customListeners);
+        }
 
         if (testsToRun.allowEagerReading()) {
             List<DiscoverySelector> selectors = new ArrayList<>();
             testsToRun.iterator().forEachRemaining(c -> 
selectors.add(selectClass(c.getName())));
 
             LauncherDiscoveryRequestBuilder builder = 
newRequest().selectors(selectors);
-            launcher.execute(builder.build(), testExecutionListeners);
+            launcher.execute(
+                    builder.build(),
+                    testExecutionListeners.toArray(new 
TestExecutionListener[testExecutionListeners.size()]));
         } else {
             testsToRun.iterator().forEachRemaining(c -> {
                 LauncherDiscoveryRequestBuilder builder = 
newRequest().selectors(selectClass(c.getName()));
-                launcher.execute(builder.build(), testExecutionListeners);
+                launcher.execute(
+                        builder.build(),
+                        testExecutionListeners.toArray(new 
TestExecutionListener[testExecutionListeners.size()]));

Review Comment:
   ```
   new TestExecutionListener[0])
   ```



##########
surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java:
##########
@@ -224,29 +221,51 @@ private void invokeAllTests(LauncherAdapter launcher, 
TestsToRun testsToRun, Run
     }
 
     private void execute(LauncherAdapter launcher, TestsToRun testsToRun, 
RunListenerAdapter adapter) {
-        // parameters.getProviderProperties().get(CONFIGURATION_PARAMETERS)
-        // add this LegacyXmlReportGeneratingListener ?
-        //            adapter,
-        //            new LegacyXmlReportGeneratingListener(
-        //                    new File("target", "junit-platform").toPath(), 
new PrintWriter(System.out))
-        //        };
+        List<TestExecutionListener> testExecutionListeners = new ArrayList<>();
+        testExecutionListeners.add(adapter);
 
-        TestExecutionListener[] testExecutionListeners = new 
TestExecutionListener[] {adapter};
+        TestExecutionListener customListeners = createCustomListener();
+        if (customListeners != null) {
+            testExecutionListeners.add(customListeners);
+        }
 
         if (testsToRun.allowEagerReading()) {
             List<DiscoverySelector> selectors = new ArrayList<>();
             testsToRun.iterator().forEachRemaining(c -> 
selectors.add(selectClass(c.getName())));
 
             LauncherDiscoveryRequestBuilder builder = 
newRequest().selectors(selectors);
-            launcher.execute(builder.build(), testExecutionListeners);
+            launcher.execute(
+                    builder.build(),
+                    testExecutionListeners.toArray(new 
TestExecutionListener[testExecutionListeners.size()]));

Review Comment:
   ```
   new TestExecutionListener[0])
   ```



##########
surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/CustomTestExecutionListener.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.surefire.junitplatform;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.junit.platform.engine.support.descriptor.ClassSource;
+import org.junit.platform.launcher.TestExecutionListener;
+import org.junit.platform.launcher.TestIdentifier;
+import org.junit.platform.launcher.TestPlan;
+
+public class CustomTestExecutionListener implements TestExecutionListener {

Review Comment:
   I would prefer a name such `JUnit4ListenersAdapter` or at least something 
JUnit4 is the reason 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to