[maven-surefire] branch SUREFIRE-1546 created (now b1ec969)

classic Classic list List threaded Threaded
2 messages Options
sor
Reply | Threaded
Open this post in threaded view
|

[maven-surefire] branch SUREFIRE-1546 created (now b1ec969)

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

sor pushed a change to branch SUREFIRE-1546
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git.


      at b1ec969  Enable display name usage via system property

This branch includes the following new commits:

     new b1ec969  Enable display name usage via system property

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.


sor
Reply | Threaded
Open this post in threaded view
|

[maven-surefire] 01/01: Enable display name usage via system property

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

sor pushed a commit to branch SUREFIRE-1546
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit b1ec96982b8fe8127c811e4ff0d2d8561fcb100b
Author: Christian Stein <[hidden email]>
AuthorDate: Fri Sep 14 09:28:53 2018 +0200

    Enable display name usage via system property
   
    Set "surefire.junit.platform.display.name.enabled=true" and the
    custom display names provided by test authors are taken into account.
   
    Issue: SUREFIRE-1546
---
 .../maven/surefire/junitplatform/RunListenerAdapter.java     | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

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 85227f3..7a25434 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
@@ -90,7 +90,7 @@ final class RunListenerAdapter
     {
         ensureTestSetStarted( testIdentifier );
         String source = getLegacyReportingClassName( testIdentifier );
-        runListener.testSkipped( ignored( source, getLegacyReportingName( testIdentifier ), reason ) );
+        runListener.testSkipped( ignored( source, getReportingName( testIdentifier ), reason ) );
         completeTestSetIfNecessary( testIdentifier );
     }
 
@@ -186,7 +186,7 @@ final class RunListenerAdapter
     private SimpleReportEntry createTestSetReportEntry( TestIdentifier testIdentifier )
     {
         return new SimpleReportEntry(
-                        JUnitPlatformProvider.class.getName(), testIdentifier.getLegacyReportingName() );
+                        JUnitPlatformProvider.class.getName(), getReportingName( testIdentifier ) );
     }
 
     private SimpleReportEntry createReportEntry( TestIdentifier testIdentifier )
@@ -205,13 +205,17 @@ final class RunListenerAdapter
                     TestIdentifier testIdentifier, StackTraceWriter stackTraceWriter )
     {
         String source = getLegacyReportingClassName( testIdentifier );
-        String name = getLegacyReportingName( testIdentifier );
+        String name = getReportingName( testIdentifier );
 
         return SimpleReportEntry.withException( source, name, stackTraceWriter );
     }
 
-    private String getLegacyReportingName( TestIdentifier testIdentifier )
+    private String getReportingName( TestIdentifier testIdentifier )
     {
+        if ( Boolean.getBoolean( "surefire.junit.platform.display.name.enabled" ) )
+        {
+            return testIdentifier.getDisplayName();
+        }
         // Surefire cuts off the name at the first '(' character. Thus, we have to pick a different
         // character to represent parentheses. "()" are removed entirely to maximize compatibility with
         // existing reporting tools because in the old days test methods used to not have parameters.