This is an automated email from the ASF dual-hosted git repository. tibordigana pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
The following commit(s) were added to refs/heads/master by this push: new c391947 [SUREFIRE-1701] Use literal names instead of display names for classes/methods for test reruns c391947 is described below commit c391947070c9514c1d3a5ba45762329d0beb0f39 Author: Matt <co...@users.noreply.github.com> AuthorDate: Mon Oct 28 19:17:32 2019 -0400 [SUREFIRE-1701] Use literal names instead of display names for classes/methods for test reruns --- .../junitplatform/JUnitPlatformProvider.java | 7 ++--- .../junitplatform/JUnitPlatformProviderTest.java | 31 +++++++++++++++++++++- 2 files changed, 34 insertions(+), 4 deletions(-) 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 6c6c8e9..f9a650d 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 @@ -43,6 +43,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Properties; +import java.util.HashSet; import java.util.logging.Logger; import org.apache.maven.surefire.providerapi.AbstractProvider; @@ -187,12 +188,12 @@ public class JUnitPlatformProvider LauncherDiscoveryRequestBuilder builder = request().filters( filters ).configurationParameters( configurationParameters ); // Iterate over recorded failures - for ( TestIdentifier identifier : adapter.getFailures().keySet() ) + for ( TestIdentifier identifier : new HashSet<>( adapter.getFailures().keySet() ) ) { // Extract quantified test name data String[] classMethodName = adapter.toClassMethodNameWithoutPlan( identifier ); - String className = classMethodName[1]; - String methodName = classMethodName[3]; + String className = classMethodName[0]; + String methodName = classMethodName[2]; // Add filter for the specific failing method builder.selectors( selectMethod( className, methodName ) ); } 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 feb169c..954bb12 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 @@ -43,6 +43,7 @@ import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -211,6 +212,15 @@ public class JUnitPlatformProviderTest assertEquals( 1, summary.getTestsSucceededCount() ); assertEquals( 1, summary.getTestsAbortedCount() ); assertEquals( 3, summary.getTestsFailedCount() ); + Set<String> failDisplays = new HashSet<>(); + for ( TestExecutionSummary.Failure failure : summary.getFailures() ) + { + failDisplays.add( failure.getTestIdentifier().getDisplayName() ); + } + assertEquals( 3, failDisplays.size() ); + assertTrue( failDisplays.contains( "Fails twice" ) ); + assertTrue( failDisplays.contains( "testAlwaysFail()" ) ); + assertTrue( failDisplays.contains( "testAlwaysError()" ) ); // Should rerun both of the failures summary = executionListener.summaries.get( 1 ); @@ -220,6 +230,15 @@ public class JUnitPlatformProviderTest assertEquals( 0, summary.getTestsSucceededCount() ); assertEquals( 0, summary.getTestsAbortedCount() ); assertEquals( 3, summary.getTestsFailedCount() ); + failDisplays.clear(); + for ( TestExecutionSummary.Failure failure : summary.getFailures() ) + { + failDisplays.add( failure.getTestIdentifier().getDisplayName() ); + } + assertEquals( 3, failDisplays.size() ); + assertTrue( failDisplays.contains( "Fails twice" ) ); + assertTrue( failDisplays.contains( "testAlwaysFail()" ) ); + assertTrue( failDisplays.contains( "testAlwaysError()" ) ); // now only one failure should remain summary = executionListener.summaries.get( 2 ); @@ -229,6 +248,14 @@ public class JUnitPlatformProviderTest assertEquals( 1, summary.getTestsSucceededCount() ); assertEquals( 0, summary.getTestsAbortedCount() ); assertEquals( 2, summary.getTestsFailedCount() ); + failDisplays.clear(); + for ( TestExecutionSummary.Failure failure : summary.getFailures() ) + { + failDisplays.add( failure.getTestIdentifier().getDisplayName() ); + } + assertEquals( 2, failDisplays.size() ); + assertTrue( failDisplays.contains( "testAlwaysFail()" ) ); + assertTrue( failDisplays.contains( "testAlwaysError()" ) ); } @Test @@ -834,6 +861,7 @@ public class JUnitPlatformProviderTest { static int count; + @org.junit.jupiter.api.DisplayName( "Always passes" ) @org.junit.jupiter.api.Test void testPass() { @@ -843,7 +871,7 @@ public class JUnitPlatformProviderTest void testAborted() { assumeFalse( true ); - throw new IllegalStateException( "this exception should neve happen" ); + throw new IllegalStateException( "this exception should never happen" ); } @org.junit.jupiter.api.Test @@ -865,6 +893,7 @@ public class JUnitPlatformProviderTest throw new IllegalStateException( "this test should be never called" ); } + @org.junit.jupiter.api.DisplayName( "Fails twice" ) @org.junit.jupiter.api.Test void testFailTwice() {