You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2023/02/03 05:25:11 UTC

[maven-surefire] branch pr-516-rebase-master created (now b09185adb)

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

olamy pushed a change to branch pr-516-rebase-master
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


      at b09185adb [SUREFIRE-2065] Use legacy name to avoid retried test to make tests show as flaky on junit4

This branch includes the following new commits:

     new b09185adb [SUREFIRE-2065] Use legacy name to avoid retried test to make tests show as flaky on junit4

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-surefire] 01/01: [SUREFIRE-2065] Use legacy name to avoid retried test to make tests show as flaky on junit4

Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

olamy pushed a commit to branch pr-516-rebase-master
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit b09185adb51074439d8840c8a862d6777b9e2c0c
Author: Christian Marquez Grabia <49...@users.noreply.github.com>
AuthorDate: Mon Jun 6 00:17:31 2022 -0500

    [SUREFIRE-2065] Use legacy name to avoid retried test to make tests show as flaky on junit4
---
 .../maven/surefire/its/fixture/TestFile.java       |  19 ++++
 .../maven/surefire/its/jiras/Surefire2065IT.java   | 103 +++++++++++++++++++++
 .../test/resources/surefire-2065-common/pom.xml    |  72 ++++++++++++++
 .../test/java/pkg/junit4/ParameterizedTest.java    |  29 ++++++
 .../junit4/ParameterizedWithDisplayNameTest.java   |  31 +++++++
 .../test/java/pkg/junit5/ParameterizedTest.java    |  30 ++++++
 .../junit5/ParameterizedWithDisplayNameTest.java   |  30 ++++++
 .../test/resources/surefire-2065-junit4/pom.xml    |  59 ++++++++++++
 .../test/java/pkg/junit4/ParameterizedTest.java    |  29 ++++++
 .../junit4/ParameterizedWithDisplayNameTest.java   |  31 +++++++
 .../test/resources/surefire-2065-junit5/pom.xml    |  65 +++++++++++++
 .../test/java/pkg/junit5/ParameterizedTest.java    |  30 ++++++
 .../junit5/ParameterizedWithDisplayNameTest.java   |  30 ++++++
 .../surefire/junitplatform/RunListenerAdapter.java |  43 ++++-----
 .../junitplatform/JUnitPlatformProviderTest.java   |   6 +-
 .../junitplatform/RunListenerAdapterTest.java      |  24 ++++-
 16 files changed, 600 insertions(+), 31 deletions(-)

diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
index 88f300208..2c1fb0f0e 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
@@ -155,6 +155,25 @@ public class TestFile
         return assertContainsText( containsString( text ) );
     }
 
+    public TestFile assertNotContainsText( Matcher<String> matcher )
+    {
+        final List<String> list = surefireVerifier.loadFile( file, encoding );
+        for ( String line : list )
+        {
+            if ( matcher.matches( line ) )
+            {
+                Assert.fail( "Found unexpected message in log" );
+                return null;
+            }
+        }
+        return this;
+    }
+
+    public TestFile assertNotContainsText( String text )
+    {
+        return assertNotContainsText( containsString( text ) );
+    }
+
     public URI toURI()
     {
         return file.toURI();
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2065IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2065IT.java
new file mode 100644
index 000000000..5c6a20a68
--- /dev/null
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2065IT.java
@@ -0,0 +1,103 @@
+package org.apache.maven.surefire.its.jiras;
+
+/*
+ * 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.
+ */
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import org.apache.maven.it.VerificationException;
+import org.apache.maven.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+
+/**
+ * Integration Tests for SUREFIRE-2065
+ */
+@SuppressWarnings( "checkstyle:magicnumber" )
+public class Surefire2065IT extends SurefireJUnit4IntegrationTestCase
+{
+    @Test
+    public void shouldNotDetectFlakyTestsWhenCombiningJunit4And5Tests() throws VerificationException
+    {
+        OutputValidator validator = unpack( "surefire-2065-common" )
+            .mavenTestFailureIgnore( true )
+            .executeTest()
+            .assertTestSuiteResults( 8, 0, 4, 0, 0 );
+
+        assertJunit4( validator );
+        assertJunit5( validator );
+    }
+
+    @Test
+    public void shouldNotDetectFlakyTestsWhenRunningOnlyJunit4() throws VerificationException
+    {
+        OutputValidator validator = unpack( "surefire-2065-junit4" )
+            .mavenTestFailureIgnore( true )
+            .executeTest()
+            .assertTestSuiteResults( 4, 0, 2, 0, 0 );
+
+        assertJunit4( validator );
+    }
+
+    @Test
+    public void shouldNotDetectFlakyTestsWhenRunningOnlyJunit5() throws VerificationException
+    {
+        OutputValidator validator = unpack( "surefire-2065-junit5" )
+            .mavenTestFailureIgnore( true )
+            .executeTest()
+            .assertTestSuiteResults( 4, 0, 2, 0, 0 );
+
+        assertJunit5( validator );
+    }
+
+    private static void assertJunit4( OutputValidator validator )
+    {
+        validator.getSurefireReportsFile( "TEST-pkg.junit4.ParameterizedTest.xml", UTF_8 )
+            .assertContainsText( Matchers.matchesPattern( "^ *<testcase name=\"notFlaky\\[0]\".*/>$" ) )
+            .assertContainsText( Matchers.matchesPattern( "^ *<testcase name=\"notFlaky\\[1]\".*[^/]>$" ) )
+            .assertContainsText( "<failure message=" )
+            .assertContainsText( "<rerunFailure message=" )
+            .assertNotContainsText( "<flakyFailure message=" );
+
+        validator.getSurefireReportsFile( "TEST-pkg.junit4.ParameterizedWithDisplayNameTest.xml", UTF_8 )
+            .assertContainsText( Matchers.matchesPattern( "^ *<testcase name=\"notFlaky\\[value=0]\".*/>$" ) )
+            .assertContainsText( Matchers.matchesPattern( "^ *<testcase name=\"notFlaky\\[value=1]\".*[^/]>$" ) )
+            .assertContainsText( "<failure message=" )
+            .assertContainsText( "<rerunFailure message=" )
+            .assertNotContainsText( "<flakyFailure message=" );
+    }
+
+    private static void assertJunit5( OutputValidator validator )
+    {
+        validator.getSurefireReportsFile( "TEST-pkg.junit5.ParameterizedTest.xml", UTF_8 )
+            .assertContainsText( Matchers.matchesPattern( "^ *<testcase name=\"notFlaky\\(int\\)\\[1]\".*/>$" ) )
+            .assertContainsText( Matchers.matchesPattern( "^ *<testcase name=\"notFlaky\\(int\\)\\[2]\".*[^/]>$" ) )
+            .assertContainsText( "<failure message=" )
+            .assertContainsText( "<rerunFailure message=" )
+            .assertNotContainsText( "<flakyFailure message=" );
+
+        validator.getSurefireReportsFile( "TEST-pkg.junit5.ParameterizedWithDisplayNameTest.xml", UTF_8 )
+            .assertContainsText( Matchers.matchesPattern( "^ *<testcase name=\"notFlaky\\(int\\)\\[1]\".*/>$" ) )
+            .assertContainsText( Matchers.matchesPattern( "^ *<testcase name=\"notFlaky\\(int\\)\\[2]\".*[^/]>$" ) )
+            .assertContainsText( "<failure message=" )
+            .assertContainsText( "<rerunFailure message=" )
+            .assertNotContainsText( "<flakyFailure message=" );
+    }
+}
diff --git a/surefire-its/src/test/resources/surefire-2065-common/pom.xml b/surefire-its/src/test/resources/surefire-2065-common/pom.xml
new file mode 100644
index 000000000..90a541436
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-2065-common/pom.xml
@@ -0,0 +1,72 @@
+<?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">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.example</groupId>
+  <artifactId>surefire-2065-common</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <maven.compiler.source>${java.specification.version}</maven.compiler.source>
+    <maven.compiler.target>${java.specification.version}</maven.compiler.target>
+    <junit4.version>4.12</junit4.version>
+    <junit5.version>5.3.2</junit5.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${junit4.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <version>${junit5.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-params</artifactId>
+      <version>${junit5.version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>${surefire.version}</version>
+        <configuration>
+          <rerunFailingTestsCount>1</rerunFailingTestsCount>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/surefire-its/src/test/resources/surefire-2065-common/src/test/java/pkg/junit4/ParameterizedTest.java b/surefire-its/src/test/resources/surefire-2065-common/src/test/java/pkg/junit4/ParameterizedTest.java
new file mode 100644
index 000000000..1456a8138
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-2065-common/src/test/java/pkg/junit4/ParameterizedTest.java
@@ -0,0 +1,29 @@
+package pkg.junit4;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class ParameterizedTest
+{
+    @Parameterized.Parameters
+    public static List<Integer> parameters() throws Exception
+    {
+        return Arrays.asList( 0, 1 );
+    }
+
+    @Parameterized.Parameter(0)
+    public int expected;
+
+    @Test
+    public void notFlaky()
+    {
+        assertEquals( expected, 0 );
+    }
+}
diff --git a/surefire-its/src/test/resources/surefire-2065-common/src/test/java/pkg/junit4/ParameterizedWithDisplayNameTest.java b/surefire-its/src/test/resources/surefire-2065-common/src/test/java/pkg/junit4/ParameterizedWithDisplayNameTest.java
new file mode 100644
index 000000000..af0029360
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-2065-common/src/test/java/pkg/junit4/ParameterizedWithDisplayNameTest.java
@@ -0,0 +1,31 @@
+package pkg.junit4;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class ParameterizedWithDisplayNameTest
+{
+    private static int count = 0;
+
+    @Parameterized.Parameters(name = "value={0}")
+    public static List<Integer> parameters() throws Exception
+    {
+        return Arrays.asList( 0, 1 );
+    }
+
+    @Parameterized.Parameter(0)
+    public int expected;
+
+    @Test
+    public void notFlaky()
+    {
+        assertEquals( expected, 0 );
+    }
+}
diff --git a/surefire-its/src/test/resources/surefire-2065-common/src/test/java/pkg/junit5/ParameterizedTest.java b/surefire-its/src/test/resources/surefire-2065-common/src/test/java/pkg/junit5/ParameterizedTest.java
new file mode 100644
index 000000000..ec2b2fbc5
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-2065-common/src/test/java/pkg/junit5/ParameterizedTest.java
@@ -0,0 +1,30 @@
+package pkg.junit5;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.Arrays;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
+
+class ParameterizedTest
+{
+    static class ParameterSource implements ArgumentsProvider
+    {
+        @Override
+        public Stream<? extends Arguments> provideArguments( ExtensionContext context ) throws Exception
+        {
+            return Arrays.asList(0, 1).stream().map( Arguments::of );
+        }
+    }
+
+    @org.junit.jupiter.params.ParameterizedTest
+    @ArgumentsSource(value = ParameterSource.class)
+    public void notFlaky(int expected)
+    {
+        assertEquals( expected, 0 );
+    }
+}
diff --git a/surefire-its/src/test/resources/surefire-2065-common/src/test/java/pkg/junit5/ParameterizedWithDisplayNameTest.java b/surefire-its/src/test/resources/surefire-2065-common/src/test/java/pkg/junit5/ParameterizedWithDisplayNameTest.java
new file mode 100644
index 000000000..94cd8a34a
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-2065-common/src/test/java/pkg/junit5/ParameterizedWithDisplayNameTest.java
@@ -0,0 +1,30 @@
+package pkg.junit5;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.Arrays;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
+
+class ParameterizedWithDisplayNameTest
+{
+    static class ParameterSource implements ArgumentsProvider
+    {
+        @Override
+        public Stream<? extends Arguments> provideArguments( ExtensionContext context ) throws Exception
+        {
+            return Arrays.asList(0, 1).stream().map( Arguments::of );
+        }
+    }
+
+    @org.junit.jupiter.params.ParameterizedTest(name = "value={0}")
+    @ArgumentsSource(value = ParameterSource.class)
+    public void notFlaky(int expected)
+    {
+        assertEquals( expected, 0 );
+    }
+}
diff --git a/surefire-its/src/test/resources/surefire-2065-junit4/pom.xml b/surefire-its/src/test/resources/surefire-2065-junit4/pom.xml
new file mode 100644
index 000000000..fa6470cc4
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-2065-junit4/pom.xml
@@ -0,0 +1,59 @@
+<?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">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.example</groupId>
+  <artifactId>surefire-2065-junit4</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <maven.compiler.source>${java.specification.version}</maven.compiler.source>
+    <maven.compiler.target>${java.specification.version}</maven.compiler.target>
+    <junit4.version>4.12</junit4.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${junit4.version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>${surefire.version}</version>
+        <configuration>
+          <rerunFailingTestsCount>1</rerunFailingTestsCount>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/surefire-its/src/test/resources/surefire-2065-junit4/src/test/java/pkg/junit4/ParameterizedTest.java b/surefire-its/src/test/resources/surefire-2065-junit4/src/test/java/pkg/junit4/ParameterizedTest.java
new file mode 100644
index 000000000..1456a8138
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-2065-junit4/src/test/java/pkg/junit4/ParameterizedTest.java
@@ -0,0 +1,29 @@
+package pkg.junit4;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class ParameterizedTest
+{
+    @Parameterized.Parameters
+    public static List<Integer> parameters() throws Exception
+    {
+        return Arrays.asList( 0, 1 );
+    }
+
+    @Parameterized.Parameter(0)
+    public int expected;
+
+    @Test
+    public void notFlaky()
+    {
+        assertEquals( expected, 0 );
+    }
+}
diff --git a/surefire-its/src/test/resources/surefire-2065-junit4/src/test/java/pkg/junit4/ParameterizedWithDisplayNameTest.java b/surefire-its/src/test/resources/surefire-2065-junit4/src/test/java/pkg/junit4/ParameterizedWithDisplayNameTest.java
new file mode 100644
index 000000000..af0029360
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-2065-junit4/src/test/java/pkg/junit4/ParameterizedWithDisplayNameTest.java
@@ -0,0 +1,31 @@
+package pkg.junit4;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class ParameterizedWithDisplayNameTest
+{
+    private static int count = 0;
+
+    @Parameterized.Parameters(name = "value={0}")
+    public static List<Integer> parameters() throws Exception
+    {
+        return Arrays.asList( 0, 1 );
+    }
+
+    @Parameterized.Parameter(0)
+    public int expected;
+
+    @Test
+    public void notFlaky()
+    {
+        assertEquals( expected, 0 );
+    }
+}
diff --git a/surefire-its/src/test/resources/surefire-2065-junit5/pom.xml b/surefire-its/src/test/resources/surefire-2065-junit5/pom.xml
new file mode 100644
index 000000000..8241ef480
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-2065-junit5/pom.xml
@@ -0,0 +1,65 @@
+<?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">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.example</groupId>
+  <artifactId>surefire-2065-junit5</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <maven.compiler.source>${java.specification.version}</maven.compiler.source>
+    <maven.compiler.target>${java.specification.version}</maven.compiler.target>
+    <junit5.version>5.3.2</junit5.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <version>${junit5.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-params</artifactId>
+      <version>${junit5.version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>${surefire.version}</version>
+        <configuration>
+          <rerunFailingTestsCount>1</rerunFailingTestsCount>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/surefire-its/src/test/resources/surefire-2065-junit5/src/test/java/pkg/junit5/ParameterizedTest.java b/surefire-its/src/test/resources/surefire-2065-junit5/src/test/java/pkg/junit5/ParameterizedTest.java
new file mode 100644
index 000000000..ec2b2fbc5
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-2065-junit5/src/test/java/pkg/junit5/ParameterizedTest.java
@@ -0,0 +1,30 @@
+package pkg.junit5;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.Arrays;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
+
+class ParameterizedTest
+{
+    static class ParameterSource implements ArgumentsProvider
+    {
+        @Override
+        public Stream<? extends Arguments> provideArguments( ExtensionContext context ) throws Exception
+        {
+            return Arrays.asList(0, 1).stream().map( Arguments::of );
+        }
+    }
+
+    @org.junit.jupiter.params.ParameterizedTest
+    @ArgumentsSource(value = ParameterSource.class)
+    public void notFlaky(int expected)
+    {
+        assertEquals( expected, 0 );
+    }
+}
diff --git a/surefire-its/src/test/resources/surefire-2065-junit5/src/test/java/pkg/junit5/ParameterizedWithDisplayNameTest.java b/surefire-its/src/test/resources/surefire-2065-junit5/src/test/java/pkg/junit5/ParameterizedWithDisplayNameTest.java
new file mode 100644
index 000000000..94cd8a34a
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-2065-junit5/src/test/java/pkg/junit5/ParameterizedWithDisplayNameTest.java
@@ -0,0 +1,30 @@
+package pkg.junit5;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.Arrays;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
+
+class ParameterizedWithDisplayNameTest
+{
+    static class ParameterSource implements ArgumentsProvider
+    {
+        @Override
+        public Stream<? extends Arguments> provideArguments( ExtensionContext context ) throws Exception
+        {
+            return Arrays.asList(0, 1).stream().map( Arguments::of );
+        }
+    }
+
+    @org.junit.jupiter.params.ParameterizedTest(name = "value={0}")
+    @ArgumentsSource(value = ParameterSource.class)
+    public void notFlaky(int expected)
+    {
+        assertEquals( expected, 0 );
+    }
+}
diff --git a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java
index 3e4e605e5..76a61f908 100644
--- a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java
+++ b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java
@@ -33,7 +33,6 @@ import java.util.Objects;
 import java.util.Optional;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
-import java.util.regex.Pattern;
 import java.util.stream.Stream;
 
 import org.apache.maven.surefire.api.report.OutputReportEntry;
@@ -61,8 +60,6 @@ import org.junit.platform.launcher.TestPlan;
 final class RunListenerAdapter
     implements TestExecutionListener, TestOutputReceiver<OutputReportEntry>, RunModeSetter
 {
-    private static final Pattern COMMA_PATTERN = Pattern.compile( "," );
-
     private final ClassMethodIndexer classMethodIndexer = new ClassMethodIndexer();
     private final ConcurrentMap<TestIdentifier, Long> testStartTime = new ConcurrentHashMap<>();
     private final ConcurrentMap<TestIdentifier, TestExecutionResult> failures = new ConcurrentHashMap<>();
@@ -147,7 +144,7 @@ final class RunListenerAdapter
                     break;
                 case FAILED:
                     String reason = safeGetMessage( testExecutionResult.getThrowable().orElse( null ) );
-                    SimpleReportEntry reportEntry = createReportEntry( testIdentifier, testExecutionResult, 
+                    SimpleReportEntry reportEntry = createReportEntry( testIdentifier, testExecutionResult,
                             reason, elapsed );
                     if ( isAssertionError )
                     {
@@ -320,7 +317,9 @@ final class RunListenerAdapter
             MethodSource methodSource = testSource.map( MethodSource.class::cast ).get();
             String realClassName = methodSource.getClassName();
 
-            String[] source = testPlan.getParent( testIdentifier )
+            String[] source = collectAllTestIdentifiersInHierarchy( testIdentifier )
+                    .filter( i -> i.getSource().map( ClassSource.class::isInstance ).orElse( false ) )
+                    .findFirst()
                     .map( this::toClassMethodName )
                     .map( s -> new String[] { s[0], s[1] } )
                     .orElse( new String[] { realClassName, realClassName } );
@@ -334,28 +333,26 @@ final class RunListenerAdapter
             boolean needsSpaceSeparator = isNotBlank( parentDisplay ) && !display.startsWith( "[" );
             String methodDisplay = parentDisplay + ( needsSpaceSeparator ? " " : "" ) + display;
 
-            String simpleClassNames = COMMA_PATTERN.splitAsStream( methodSource.getMethodParameterTypes() )
-                    .map( s -> s.substring( 1 + s.lastIndexOf( '.' ) ) )
-                    .collect( joining( "," ) );
-
-            boolean hasParams = isNotBlank( methodSource.getMethodParameterTypes() );
-            String methodName = methodSource.getMethodName();
+            // SUREFIRE-2065 (see tables below)
             String description = testIdentifier.getLegacyReportingName();
-            String methodSign = hasParams ? methodName + '(' + simpleClassNames + ')' : methodName;
-            boolean equalDescriptions = methodDisplay.equals( description );
-            boolean hasLegacyDescription = description.startsWith( methodName + '(' );
-            boolean hasDisplayName = !equalDescriptions || !hasLegacyDescription;
-            String methodDesc = equalDescriptions || !hasParams ? methodSign : description;
-            String methodDisp = hasDisplayName ? methodDisplay : methodDesc;
-
-            // The behavior of methods getLegacyReportingName() and getDisplayName().
-            //     test      ||  legacy  |  display
+
+            // For better handling of parameterized junit4, use of LegacyReportingName as description
+            // fits better since display and legacy are same for parameterized junit4
+            //     junit4    ||  legacy  |  display
+            // ==============||==========|==========
+            //     normal    ||     m    |     m
+            //     param     ||   m[0]   |   m[0]
+            //  param+displ  || m[displ] | m[displ]
+
+            // For junit5 legacy / display behaves as below
+            //     junit5    ||  legacy  |  display
             // ==============||==========|==========
             //    normal     ||    m()   |    m()
-            //  normal+displ ||   displ  |  displ
-            // parameterized ||  m()[1]  |  displ
+            //  normal+displ ||    m()   |   displ
+            //     param     ||  m()[1]  | [1] <param>
+            //  param+displ  ||  m()[1]  |   displ
 
-            return new String[] {source[0], source[1], methodDesc, methodDisp};
+            return new String[] {source[0], source[1], description, methodDisplay};
         }
         else if ( testSource.filter( ClassSource.class::isInstance ).isPresent() )
         {
diff --git a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProviderTest.java b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProviderTest.java
index 9e376cc06..af3ff1ade 100644
--- a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProviderTest.java
+++ b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProviderTest.java
@@ -449,7 +449,7 @@ public class JUnitPlatformProviderTest
 
         assertEquals( DisplayNameTest.class.getName(), reportEntries.get( 0 ).getSourceName() );
         assertEquals( "<< ✨ >>", reportEntries.get( 0 ).getSourceText() );
-        assertEquals( "test1", reportEntries.get( 0 ).getName() );
+        assertEquals( "test1()", reportEntries.get( 0 ).getName() );
         assertEquals( "73$71 ✔", reportEntries.get( 0 ).getNameText() );
     }
 
@@ -515,7 +515,7 @@ public class JUnitPlatformProviderTest
 
         assertEquals( TestClass8.class.getName(), reportEntries.get( 0 ).getSourceName() );
         assertNull( reportEntries.get( 0 ).getSourceText() );
-        assertEquals( "testParameterizedTestCases", reportEntries.get( 0 ).getName() );
+        assertEquals( "testParameterizedTestCases()", reportEntries.get( 0 ).getName() );
         assertNull( reportEntries.get( 0 ).getNameText() );
 
         TestExecutionSummary summary = executionListener.summaries.get( 0 );
@@ -554,7 +554,7 @@ public class JUnitPlatformProviderTest
 
         assertEquals( TestClass9.class.getName(), reportEntries.get( 0 ).getSourceName() );
         assertNull( reportEntries.get( 0 ).getSourceText() );
-        assertEquals( "testParameterizedTestCases", reportEntries.get( 0 ).getName() );
+        assertEquals( "testParameterizedTestCases()", reportEntries.get( 0 ).getName() );
         assertNull( reportEntries.get( 0 ).getNameText() );
 
         TestExecutionSummary summary = executionListener.summaries.get( 0 );
diff --git a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
index e790bde1e..3b920e112 100644
--- a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
+++ b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
@@ -112,7 +112,7 @@ public class RunListenerAdapterTest
         verify( listener ).testStarting( entryCaptor.capture() );
 
         ReportEntry entry = entryCaptor.getValue();
-        assertEquals( MY_TEST_METHOD_NAME, entry.getName() );
+        assertEquals( MY_TEST_METHOD_NAME.concat( "()" ), entry.getName() );
         assertEquals( MyTestClass.class.getName(), entry.getSourceName() );
         assertNull( entry.getStackTraceWriter() );
     }
@@ -162,7 +162,7 @@ public class RunListenerAdapterTest
 
         adapter.executionStarted( TestIdentifier.from( child ) );
         verify( listener ).testStarting( new SimpleReportEntry( NORMAL_RUN, 0x0000000100000001L, className, null,
-            MY_TEST_METHOD_NAME, null ) );
+            MY_TEST_METHOD_NAME.concat( "()" ), null ) );
         verifyNoMoreInteractions( listener );
 
         adapter.executionFinished( TestIdentifier.from( child ), successful() );
@@ -177,7 +177,7 @@ public class RunListenerAdapterTest
         assertThat( report.getValue().getSourceText() )
                 .isNull();
         assertThat( report.getValue().getName() )
-                .isEqualTo( MY_TEST_METHOD_NAME );
+                .isEqualTo( MY_TEST_METHOD_NAME.concat( "()" ) );
         assertThat( report.getValue().getNameText() )
                 .isNull();
         assertThat( report.getValue().getElapsed() )
@@ -538,7 +538,7 @@ public class RunListenerAdapterTest
 
         ReportEntry entry = entryCaptor.getValue();
         assertEquals( MyTestClass.class.getTypeName(), entry.getSourceName() );
-        assertEquals( MY_TEST_METHOD_NAME, entry.getName() );
+        assertEquals( MY_TEST_METHOD_NAME.concat( "()" ), entry.getName() );
         assertNotNull( entry.getStackTraceWriter() );
         assertNotNull( entry.getStackTraceWriter().getThrowable() );
         assertThat( entry.getStackTraceWriter().getThrowable().getTarget() )
@@ -812,10 +812,24 @@ public class RunListenerAdapterTest
 
     static class TestMethodTestDescriptorWithDisplayName extends AbstractTestDescriptor
     {
+        private final String legacyName;
+
         private TestMethodTestDescriptorWithDisplayName( UniqueId uniqueId,
                                                          Class<?> testClass, Method testMethod, String displayName )
         {
-            super( uniqueId, displayName, MethodSource.from( testClass, testMethod ) );
+            this( uniqueId, displayName, MethodSource.from( testClass, testMethod ) );
+        }
+
+        private TestMethodTestDescriptorWithDisplayName( UniqueId uniqueId, String displayName, MethodSource source )
+        {
+            super( uniqueId, displayName, source );
+            legacyName = source.getMethodName();
+        }
+
+        @Override
+        public String getLegacyReportingName()
+        {
+            return legacyName;
         }
 
         @Override