You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2022/12/23 09:35:15 UTC
[maven-surefire] branch master updated: [SUREFIRE-2032] Fix test count when using @Disabled at class level (#564)
This is an automated email from the ASF dual-hosted git repository.
gnodet 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 4545bca6d [SUREFIRE-2032] Fix test count when using @Disabled at class level (#564)
4545bca6d is described below
commit 4545bca6d913a2606fe4c78c876854a0011c901c
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Dec 23 10:35:10 2022 +0100
[SUREFIRE-2032] Fix test count when using @Disabled at class level (#564)
---
.../surefire/junitplatform/RunListenerAdapter.java | 21 ++++++++++-
.../junitplatform/RunListenerAdapterTest.java | 44 ++++++++++++++--------
2 files changed, 47 insertions(+), 18 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 aeb24576e..7272f3628 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
@@ -210,8 +210,25 @@ final class RunListenerAdapter
@Override
public void executionSkipped( TestIdentifier testIdentifier, String reason )
{
- testStartTime.remove( testIdentifier );
- runListener.testSkipped( createReportEntry( testIdentifier, null, emptyMap(), reason, null ) );
+ boolean isClass = testIdentifier.isContainer()
+ && testIdentifier.getSource().filter( ClassSource.class::isInstance ).isPresent();
+ boolean isTest = testIdentifier.isTest();
+
+ if ( isClass )
+ {
+ SimpleReportEntry report = createReportEntry( testIdentifier );
+ runListener.testSetStarting( report );
+ for ( TestIdentifier child : testPlan.getChildren( testIdentifier ) )
+ {
+ runListener.testSkipped( createReportEntry( child, null, emptyMap(), reason, null ) );
+ }
+ runListener.testSetCompleted( report );
+ }
+ else if ( isTest )
+ {
+ testStartTime.remove( testIdentifier );
+ runListener.testSkipped( createReportEntry( testIdentifier, null, emptyMap(), reason, null ) );
+ }
}
private SimpleReportEntry createReportEntry( TestIdentifier testIdentifier,
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 3c1e12905..e790bde1e 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
@@ -48,6 +48,7 @@ import java.util.Optional;
import org.apache.maven.surefire.api.report.TestOutputReportEntry;
import org.apache.maven.surefire.api.report.TestReportListener;
+import org.apache.maven.surefire.api.report.TestSetReportEntry;
import org.apache.maven.surefire.report.PojoStackTraceWriter;
import org.apache.maven.surefire.api.report.ReportEntry;
import org.apache.maven.surefire.api.report.SimpleReportEntry;
@@ -394,28 +395,39 @@ public class RunListenerAdapterTest
}
@Test
- public void notifiedWithCorrectNamesWhenClassExecutionSkipped()
- {
- ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass( ReportEntry.class );
- TestPlan testPlan = TestPlan.from( singletonList( new EngineDescriptor( newId(), "Luke's Plan" ) ) );
+ public void notifiedWithCorrectNamesWhenClassExecutionSkipped() throws Exception
+ {
+ EngineDescriptor engineDescriptor = new EngineDescriptor( newId(), "Luke's Plan" );
+ TestDescriptor classTestDescriptor = newClassDescriptor();
+ TestDescriptor method1 = newMethodDescriptor();
+ classTestDescriptor.addChild( method1 );
+ TestDescriptor method2 = newMethodDescriptor();
+ classTestDescriptor.addChild( method2 );
+ engineDescriptor.addChild( classTestDescriptor );
+ TestPlan testPlan = TestPlan.from( singletonList( engineDescriptor ) );
adapter.testPlanExecutionStarted( testPlan );
TestIdentifier classIdentifier =
identifiersAsParentOnTestPlan( testPlan, newEngineDescriptor(), newClassDescriptor() );
- adapter.executionSkipped( classIdentifier, "test" );
- verify( listener ).testSkipped( entryCaptor.capture() );
-
- ReportEntry entry = entryCaptor.getValue();
- assertNull( entry.getName() );
- assertEquals( MyTestClass.class.getTypeName(), entry.getSourceName() );
- }
+ ArgumentCaptor<TestSetReportEntry> entryCaptor1 = ArgumentCaptor.forClass( TestSetReportEntry.class );
+ ArgumentCaptor<ReportEntry> entryCaptor2 = ArgumentCaptor.forClass( ReportEntry.class );
+ ArgumentCaptor<ReportEntry> entryCaptor3 = ArgumentCaptor.forClass( ReportEntry.class );
+ ArgumentCaptor<TestSetReportEntry> entryCaptor4 = ArgumentCaptor.forClass( TestSetReportEntry.class );
- @Test
- public void notifiedWhenEngineExecutionSkipped()
- {
- adapter.executionSkipped( newEngineIdentifier(), "test" );
- verify( listener ).testSkipped( any() );
+ adapter.executionSkipped( classIdentifier, "test" );
+ verify( listener ).testSetStarting( entryCaptor1.capture() );
+ verify( listener ).testSkipped( entryCaptor2.capture() );
+ verify( listener ).testSkipped( entryCaptor3.capture() );
+ verify( listener ).testSetCompleted( entryCaptor4.capture() );
+
+ ReportEntry entry1 = entryCaptor1.getValue();
+ assertNull( entry1.getName() );
+ assertEquals( MyTestClass.class.getTypeName(), entry1.getSourceName() );
+
+ ReportEntry entry4 = entryCaptor1.getValue();
+ assertNull( entry4.getName() );
+ assertEquals( MyTestClass.class.getTypeName(), entry4.getSourceName() );
}
@Test