diff --git a/pom.xml b/pom.xml
index 1db5820847..9004b0adc2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -93,6 +93,7 @@
1.21
2.12.0
1.1.2
+ 5.9.3
3.3.4
2.0.9
@@ -240,17 +241,17 @@
org.junit.platform
junit-platform-launcher
- 1.3.2
+ 1.9.2
org.junit.jupiter
junit-jupiter-engine
- 5.3.2
+ ${junit5Version}
org.junit.jupiter
junit-jupiter-params
- 5.3.2
+ ${junit5Version}
org.mockito
diff --git a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/LazyLauncher.java b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/LazyLauncher.java
index 76b4a2e75b..6d4b000686 100644
--- a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/LazyLauncher.java
+++ b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/LazyLauncher.java
@@ -20,6 +20,7 @@
import org.apache.maven.surefire.api.util.ReflectionUtils;
import org.junit.platform.launcher.Launcher;
+import org.junit.platform.launcher.LauncherDiscoveryListener;
import org.junit.platform.launcher.LauncherDiscoveryRequest;
import org.junit.platform.launcher.TestExecutionListener;
import org.junit.platform.launcher.TestPlan;
@@ -34,6 +35,11 @@ class LazyLauncher implements Launcher, AutoCloseable {
private Launcher launcher;
+ @Override
+ public void registerLauncherDiscoveryListeners(LauncherDiscoveryListener... listeners) {
+ launcher().registerLauncherDiscoveryListeners(listeners);
+ }
+
@Override
public void registerTestExecutionListeners(TestExecutionListener... testExecutionListeners) {
launcher().registerTestExecutionListeners(testExecutionListeners);
@@ -50,6 +56,11 @@ public void execute(
launcher().execute(launcherDiscoveryRequest, testExecutionListeners);
}
+ @Override
+ public void execute(TestPlan testPlan, TestExecutionListener... listeners) {
+ launcher().execute(testPlan, listeners);
+ }
+
private Launcher launcher() {
if (launcher == null) {
try {
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 b6ab26364b..b75ac6aa68 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
@@ -32,6 +32,9 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.DisplayNameGenerator;
+import org.junit.jupiter.engine.config.DefaultJupiterConfiguration;
+import org.junit.jupiter.engine.config.JupiterConfiguration;
import org.junit.jupiter.engine.descriptor.ClassTestDescriptor;
import org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor;
import org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor;
@@ -89,7 +92,7 @@ public class RunListenerAdapterTest {
public void setUp() {
listener = mock(TestReportListener.class);
adapter = new RunListenerAdapter(listener);
- adapter.testPlanExecutionStarted(TestPlan.from(emptyList()));
+ adapter.testPlanExecutionStarted(TestPlan.from(emptyList(), CONFIG_PARAMS));
adapter.setRunMode(NORMAL_RUN);
}
@@ -97,7 +100,7 @@ public void setUp() {
public void notifiedWithCorrectNamesWhenMethodExecutionStarted() throws Exception {
ArgumentCaptor entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
- TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
+ TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS);
adapter.testPlanExecutionStarted(testPlan);
TestIdentifier methodIdentifier =
@@ -116,7 +119,7 @@ public void notifiedWithCorrectNamesWhenMethodExecutionStarted() throws Exceptio
public void notifiedWithCompatibleNameForMethodWithArguments() throws Exception {
ArgumentCaptor entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
- TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
+ TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS);
adapter.testPlanExecutionStarted(testPlan);
TestIdentifier methodIdentifier =
@@ -140,7 +143,7 @@ public void notifiedEagerlyForTestSetWhenClassExecutionStarted() throws Exceptio
engine.addChild(parent);
TestDescriptor child = newMethodDescriptor();
parent.addChild(child);
- TestPlan plan = TestPlan.from(singletonList(engine));
+ TestPlan plan = TestPlan.from(singletonList(engine), CONFIG_PARAMS);
String className = MyTestClass.class.getName();
@@ -196,10 +199,11 @@ public void displayNamesInClassAndMethods() throws Exception {
UniqueId id2 = parent.getUniqueId().append(MyTestClass.class.getName(), MY_TEST_METHOD_NAME);
Method m2 = MyTestClass.class.getDeclaredMethod(MY_TEST_METHOD_NAME, String.class);
- TestDescriptor child2 = new TestMethodTestDescriptor(id2, MyTestClass.class, m2);
+ TestDescriptor child2 = new TestMethodTestDescriptor(
+ id2, MyTestClass.class, m2, new DefaultJupiterConfiguration(CONFIG_PARAMS));
parent.addChild(child2);
- TestPlan plan = TestPlan.from(singletonList(engine));
+ TestPlan plan = TestPlan.from(singletonList(engine), CONFIG_PARAMS);
InOrder inOrder = inOrder(listener);
@@ -291,7 +295,7 @@ public Type getType() {
return TEST;
}
};
- TestPlan plan = TestPlan.from(singletonList(engine));
+ TestPlan plan = TestPlan.from(singletonList(engine), CONFIG_PARAMS);
adapter.testPlanExecutionStarted(plan);
assertThat((TestPlan) getInternalState(adapter, "testPlan")).isSameAs(plan);
@@ -343,7 +347,7 @@ public void notifiedWithCorrectNamesWhenClassExecutionSkipped() throws Exception
TestDescriptor method2 = newMethodDescriptor();
classTestDescriptor.addChild(method2);
engineDescriptor.addChild(classTestDescriptor);
- TestPlan testPlan = TestPlan.from(singletonList(engineDescriptor));
+ TestPlan testPlan = TestPlan.from(singletonList(engineDescriptor), CONFIG_PARAMS);
adapter.testPlanExecutionStarted(testPlan);
TestIdentifier classIdentifier =
@@ -414,7 +418,7 @@ public void notifiedWhenMethodExecutionFailedWithError() throws Exception {
@Test
public void notifiedWithCorrectNamesWhenClassExecutionFailed() {
ArgumentCaptor entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
- TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
+ TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS);
adapter.testPlanExecutionStarted(testPlan);
adapter.executionFinished(
@@ -432,7 +436,7 @@ public void notifiedWithCorrectNamesWhenClassExecutionFailed() {
@Test
public void notifiedWithCorrectNamesWhenClassExecutionErrored() {
ArgumentCaptor entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
- TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
+ TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS);
adapter.testPlanExecutionStarted(testPlan);
adapter.executionFinished(
@@ -450,7 +454,7 @@ public void notifiedWithCorrectNamesWhenClassExecutionErrored() {
@Test
public void notifiedWithCorrectNamesWhenContainerFailed() throws Exception {
ArgumentCaptor entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
- TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
+ TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS);
adapter.testPlanExecutionStarted(testPlan);
adapter.executionFinished(newContainerIdentifier(), failed(new RuntimeException()));
@@ -475,7 +479,7 @@ public void notifiedForTestSetWhenClassExecutionSucceeded() {
EngineDescriptor engineDescriptor = newEngineDescriptor();
TestDescriptor classDescriptor = newClassDescriptor();
engineDescriptor.addChild(classDescriptor);
- adapter.testPlanExecutionStarted(TestPlan.from(singleton(engineDescriptor)));
+ adapter.testPlanExecutionStarted(TestPlan.from(singleton(engineDescriptor), CONFIG_PARAMS));
adapter.executionStarted(TestIdentifier.from(classDescriptor));
adapter.executionFinished(TestIdentifier.from(classDescriptor), successful());
@@ -505,7 +509,7 @@ public void notifiedForTestSetWhenClassExecutionSucceeded() {
@Test
public void notifiedWithParentDisplayNameWhenTestClassUnknown() {
// Set up a test plan
- TestPlan plan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
+ TestPlan plan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS);
adapter.testPlanExecutionStarted(plan);
// Use the test plan to set up child with parent.
@@ -525,7 +529,7 @@ public void notifiedWithParentDisplayNameWhenTestClassUnknown() {
@Test
public void stackTraceWriterPresentWhenParentHasSource() {
- TestPlan plan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Some Plan")));
+ TestPlan plan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Some Plan")), CONFIG_PARAMS);
adapter.testPlanExecutionStarted(plan);
TestIdentifier child =
@@ -538,7 +542,7 @@ public void stackTraceWriterPresentWhenParentHasSource() {
@Test
public void stackTraceWriterDefaultsToTestClass() {
- TestPlan plan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Some Plan")));
+ TestPlan plan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Some Plan")), CONFIG_PARAMS);
adapter.testPlanExecutionStarted(plan);
TestIdentifier child = newSourcelessChildIdentifierWithParent(plan, "Parent", null);
@@ -589,7 +593,8 @@ private static TestDescriptor newMethodDescriptor(Class>... parameterTypes) th
return new TestMethodTestDescriptor(
UniqueId.forEngine("method"),
MyTestClass.class,
- MyTestClass.class.getDeclaredMethod(MY_TEST_METHOD_NAME, parameterTypes));
+ MyTestClass.class.getDeclaredMethod(MY_TEST_METHOD_NAME, parameterTypes),
+ new DefaultJupiterConfiguration(CONFIG_PARAMS));
}
private static TestIdentifier newClassIdentifier() {
@@ -597,16 +602,20 @@ private static TestIdentifier newClassIdentifier() {
}
private static TestDescriptor newClassDescriptor(String displayName) {
+ JupiterConfiguration jupiterConfiguration = mock(JupiterConfiguration.class);
+ DisplayNameGenerator displayNameGenerator = mock(DisplayNameGenerator.class);
+ when(displayNameGenerator.generateDisplayNameForClass(MyTestClass.class))
+ .thenReturn(displayName);
+ when(jupiterConfiguration.getDefaultDisplayNameGenerator()).thenReturn(displayNameGenerator);
return new ClassTestDescriptor(
- UniqueId.root("class", MyTestClass.class.getName()),
- c -> displayName,
- MyTestClass.class,
- CONFIG_PARAMS) {};
+ UniqueId.root("class", MyTestClass.class.getName()), MyTestClass.class, jupiterConfiguration) {};
}
private static TestDescriptor newClassDescriptor() {
return new ClassTestDescriptor(
- UniqueId.root("class", MyTestClass.class.getName()), MyTestClass.class, CONFIG_PARAMS);
+ UniqueId.root("class", MyTestClass.class.getName()),
+ MyTestClass.class,
+ new DefaultJupiterConfiguration(CONFIG_PARAMS));
}
private static TestIdentifier newSourcelessChildIdentifierWithParent(
@@ -631,8 +640,8 @@ private static TestIdentifier newSourcelessChildIdentifierWithParent(
when(child.getParent()).thenReturn(Optional.of(parent));
TestIdentifier childId = TestIdentifier.from(child);
- testPlan.add(childId);
- testPlan.add(parentId);
+ testPlan.addInternal(childId);
+ testPlan.addInternal(parentId);
return childId;
}
@@ -641,7 +650,8 @@ private static TestIdentifier newContainerIdentifier() throws Exception {
return TestIdentifier.from(new TestTemplateTestDescriptor(
UniqueId.forEngine("method"),
MyTestClass.class,
- MyTestClass.class.getDeclaredMethod(MY_TEST_METHOD_NAME)));
+ MyTestClass.class.getDeclaredMethod(MY_TEST_METHOD_NAME),
+ new DefaultJupiterConfiguration(CONFIG_PARAMS)));
}
private static TestIdentifier newEngineIdentifier() {
@@ -660,15 +670,15 @@ private static TestIdentifier identifiersAsParentOnTestPlan(
TestIdentifier parentIdentifier = TestIdentifier.from(parent);
TestIdentifier childIdentifier = TestIdentifier.from(child);
- plan.add(parentIdentifier);
- plan.add(childIdentifier);
+ plan.addInternal(parentIdentifier);
+ plan.addInternal(childIdentifier);
return childIdentifier;
}
private static TestIdentifier identifiersAsParentOnTestPlan(TestPlan plan, TestDescriptor root) {
TestIdentifier rootIdentifier = TestIdentifier.from(root);
- plan.add(rootIdentifier);
+ plan.addInternal(rootIdentifier);
return rootIdentifier;
}
diff --git a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
index 18b81e5022..aa1b80a405 100644
--- a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
+++ b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
@@ -22,6 +22,7 @@
import org.apache.maven.surefire.api.testset.TestListResolver;
import org.junit.Test;
+import org.junit.jupiter.engine.config.DefaultJupiterConfiguration;
import org.junit.jupiter.engine.descriptor.ClassTestDescriptor;
import org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor;
import org.junit.platform.engine.ConfigurationParameters;
@@ -78,12 +79,13 @@ private static TestMethodTestDescriptor newTestMethodDescriptor() throws Excepti
UniqueId uniqueId = UniqueId.forEngine("method");
Class testClass = TestClass.class;
Method testMethod = testClass.getMethod("testMethod");
- return new TestMethodTestDescriptor(uniqueId, testClass, testMethod);
+ return new TestMethodTestDescriptor(
+ uniqueId, testClass, testMethod, new DefaultJupiterConfiguration(CONFIG_PARAMS));
}
private static ClassTestDescriptor newClassTestDescriptor() {
UniqueId uniqueId = UniqueId.forEngine("class");
- return new ClassTestDescriptor(uniqueId, TestClass.class, CONFIG_PARAMS);
+ return new ClassTestDescriptor(uniqueId, TestClass.class, new DefaultJupiterConfiguration(CONFIG_PARAMS));
}
/**