Copilot commented on code in PR #3489:
URL: https://github.com/apache/maven-surefire/pull/3489#discussion_r4324746315


##########
surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/TestPlanScannerFilter.java:
##########
@@ -111,7 +112,21 @@ private static Set<String> discoverClassNamesWithTests(
         LauncherDiscoveryRequest discoveryRequest =
                 
request().selectors(selectors).filters(includeAndExcludeFilters).build();
 
-        TestPlan testPlan = launcher.discover(discoveryRequest);
+        TestPlan testPlan;
+        try {
+            testPlan = launcher.discover(discoveryRequest);
+        } catch (JUnitException e) {
+            Throwable rootCause = e;
+            while (rootCause.getCause() != null) {
+                rootCause = rootCause.getCause();
+            }
+            if (rootCause == e || rootCause.getMessage() == null) {
+                throw e;
+            }
+            String message =
+                    e.getMessage() == null ? rootCause.getMessage() : 
e.getMessage() + ": " + rootCause.getMessage();
+            throw new JUnitException(message, e);
+        }

Review Comment:
   The new message composition can duplicate information if `e.getMessage()` 
already contains the deepest-cause message (common in wrapped exceptions). To 
keep messages concise and avoid repetition, consider appending the root-cause 
message only when it’s not already present (and optionally include the 
root-cause exception type for additional context).



##########
surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire3463TestNgExtensionFailureIT.java:
##########
@@ -0,0 +1,37 @@
+/*
+ * 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.its.jiras;
+
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.junit.jupiter.api.Test;
+
+/**
+ * A TestNG extension failure during JUnit Platform discovery should retain 
its cause message.
+ */
+public class Surefire3463TestNgExtensionFailureIT extends 
SurefireJUnit4IntegrationTestCase {
+
+    @Test
+    void testNgExtensionFailureIsReported() {

Review Comment:
   This IT extends `SurefireJUnit4IntegrationTestCase` but uses JUnit Jupiter’s 
`@Test`. If the `surefire-its` module runs these tests with a JUnit 4 runner, 
this method may not execute at all. Consider switching to JUnit 4’s 
`org.junit.Test` (and a `public void` method), or use a JUnit 5-compatible base 
class used elsewhere in `surefire-its`.



##########
surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestPlanScannerFilterTest.java:
##########
@@ -237,6 +242,22 @@ public void execute(TestPlan testPlan, 
TestExecutionListener... listeners) {
         }
     }
 
+    @org.junit.jupiter.api.Test
+    public void discoveryFailureIncludesRootCauseMessage() {

Review Comment:
   Using a fully-qualified `@org.junit.jupiter.api.Test` annotation is 
inconsistent with the rest of the test file (which already uses JUnit imports). 
Prefer importing `org.junit.jupiter.api.Test` and using `@Test` for readability 
and consistency.



##########
surefire-its/src/test/resources/surefire-3463-testng-extension-failure/pom.xml:
##########
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>

Review Comment:
   The POM uses `http://` URLs for the Maven namespace and schemaLocation. If 
repository conventions allow, prefer `https://` to avoid mixed-content issues 
in tooling and to align with current Maven documentation examples.



-- 
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