maven-surefire/0002-Disable-JUnit-4.8-test-grouping.patch

112 lines
6.1 KiB
Diff
Raw Normal View History

From e953698dd68a09467fcaa4a390b61c580caefa96 Mon Sep 17 00:00:00 2001
2020-04-27 08:48:18 +00:00
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Mon, 27 Apr 2020 10:45:30 +0200
Subject: [PATCH 2/4] Disable JUnit 4.8 test grouping
2020-04-27 08:48:18 +00:00
---
2023-12-13 12:21:22 +00:00
.../surefire/junitcore/JUnitCoreProvider.java | 21 +++------------
.../maven/surefire/testng/TestNGExecutor.java | 27 +------------------
2 files changed, 4 insertions(+), 44 deletions(-)
2020-04-27 08:48:18 +00:00
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
2023-12-13 12:21:22 +00:00
index f2f58fe..c09c51e 100644
2020-04-27 08:48:18 +00:00
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
2023-12-13 12:21:22 +00:00
@@ -39,7 +39,6 @@
2020-04-27 08:48:18 +00:00
import org.apache.maven.surefire.common.junit4.JUnit4RunListener;
import org.apache.maven.surefire.common.junit4.JUnitTestFailureListener;
import org.apache.maven.surefire.common.junit4.Notifier;
-import org.apache.maven.surefire.common.junit48.FilterFactory;
import org.apache.maven.surefire.common.junit48.JUnit48Reflector;
import org.apache.maven.surefire.common.junit48.JUnit48TestChecker;
import org.junit.runner.Description;
2023-12-13 12:21:22 +00:00
@@ -50,6 +49,7 @@
import static org.apache.maven.surefire.api.report.RunMode.RERUN_TEST_AFTER_FAILURE;
import static org.apache.maven.surefire.api.testset.TestListResolver.optionallyWildcardFilter;
import static org.apache.maven.surefire.api.util.TestsToRun.fromClass;
2020-04-27 08:48:18 +00:00
+import static org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil.createMatchAnyDescriptionFilter;
import static org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil.generateFailingTestDescriptions;
import static org.apache.maven.surefire.common.junit4.JUnit4RunListenerFactory.createCustomListeners;
import static org.apache.maven.surefire.common.junit4.Notifier.pureNotifier;
2023-12-13 12:21:22 +00:00
@@ -118,7 +118,7 @@ public RunResult invoke(Object forkTestSet) throws TestSetFailedException {
Notifier notifier = new Notifier(listener, getSkipAfterFailureCount());
2020-04-27 08:48:18 +00:00
// startCapture() called in createRunListener() in prior to setTestsToRun()
- Filter filter = jUnit48Reflector.isJUnit48Available() ? createJUnit48Filter() : null;
+ Filter filter = null;
2023-12-13 12:21:22 +00:00
if (testsToRun == null) {
setTestsToRun(forkTestSet);
@@ -158,8 +158,7 @@ public RunResult invoke(Object forkTestSet) throws TestSetFailedException {
i++) {
Set<Description> failures = generateFailingTestDescriptions(testFailureListener.getAllFailures());
2020-04-27 08:48:18 +00:00
testFailureListener.reset();
2023-12-13 12:21:22 +00:00
- FilterFactory filterFactory = new FilterFactory(testClassLoader);
- Filter failureDescriptionFilter = filterFactory.createMatchAnyDescriptionFilter(failures);
+ Filter failureDescriptionFilter = createMatchAnyDescriptionFilter(failures);
rerunCore.execute(testsToRun, failureDescriptionFilter);
2020-04-27 08:48:18 +00:00
}
}
2023-12-13 12:21:22 +00:00
@@ -236,20 +235,6 @@ private boolean isParallelTypes() {
2020-04-27 08:48:18 +00:00
return jUnitCoreParameters.isParallelClasses() || jUnitCoreParameters.isParallelSuites();
}
2023-12-13 12:21:22 +00:00
- private Filter createJUnit48Filter() {
- final FilterFactory factory = new FilterFactory(testClassLoader);
2020-04-27 08:48:18 +00:00
- Map<String, String> props = providerParameters.getProviderProperties();
2023-12-13 12:21:22 +00:00
- Filter groupFilter = factory.canCreateGroupFilter(props) ? factory.createGroupFilter(props) : null;
- TestListResolver methodFilter = optionallyWildcardFilter(testResolver);
2020-04-27 08:48:18 +00:00
- boolean onlyGroups = methodFilter.isEmpty() || methodFilter.isWildcard();
2023-12-13 12:21:22 +00:00
- if (onlyGroups) {
2020-04-27 08:48:18 +00:00
- return groupFilter;
2023-12-13 12:21:22 +00:00
- } else {
- Filter jUnitMethodFilter = factory.createMethodFilter(methodFilter);
- return groupFilter == null ? jUnitMethodFilter : factory.and(groupFilter, jUnitMethodFilter);
2020-04-27 08:48:18 +00:00
- }
- }
-
2023-12-13 12:21:22 +00:00
private TestsToRun scanClassPath() {
TestsToRun scanned = scanResult.applyFilter(scannerFilter, testClassLoader);
return runOrderCalculator.orderTestClasses(scanned);
2020-04-27 08:48:18 +00:00
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
2023-12-13 12:21:22 +00:00
index 020212f..299b6bf 100644
2020-04-27 08:48:18 +00:00
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
2023-12-13 12:21:22 +00:00
@@ -258,32 +258,7 @@ private static XmlMethodSelector createMethodNameFilteringSelector(TestListResol
@SuppressWarnings("checkstyle:magicnumber")
private static XmlMethodSelector createGroupMatchingSelector(Map<String, String> options)
throws TestSetFailedException {
- final String groups = options.get(ProviderParameterNames.TESTNG_GROUPS_PROP);
- final String excludedGroups = options.get(ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP);
2020-04-27 08:48:18 +00:00
-
2023-12-13 12:21:22 +00:00
- if (groups == null && excludedGroups == null) {
- return null;
- }
2020-04-27 08:48:18 +00:00
-
- // the class is available in the testClassPath
- final String clazzName = "org.apache.maven.surefire.testng.utils.GroupMatcherMethodSelector";
2023-12-13 12:21:22 +00:00
- try {
- Class<?> clazz = Class.forName(clazzName);
2020-04-27 08:48:18 +00:00
-
- // HORRIBLE hack, but TNG doesn't allow us to setup a method selector instance directly.
2023-12-13 12:21:22 +00:00
- Method method = clazz.getMethod("setGroups", String.class, String.class);
- method.invoke(null, groups, excludedGroups);
- } catch (Exception e) {
- throw new TestSetFailedException(e.getMessage(), e);
2020-04-27 08:48:18 +00:00
- }
-
- XmlMethodSelector xms = new XmlMethodSelector();
-
2023-12-13 12:21:22 +00:00
- xms.setName(clazzName);
2020-04-27 08:48:18 +00:00
- // looks to need a high value
2023-12-13 12:21:22 +00:00
- xms.setPriority(9999);
2020-04-27 08:48:18 +00:00
-
- return xms;
2023-12-13 12:21:22 +00:00
+ return null;
2020-04-27 08:48:18 +00:00
}
2023-12-13 12:21:22 +00:00
static void run(
2020-04-27 08:48:18 +00:00
--
2023-12-13 12:21:22 +00:00
2.43.0
2020-04-27 08:48:18 +00:00