Skip to content

Commit 93223f6

Browse files
committed
Remove deprecated JUnit related support in TestNG
Closes #3022
1 parent e96e133 commit 93223f6

File tree

98 files changed

+23
-3131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+23
-3131
lines changed

Diff for: CHANGES.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
Current
2+
7.10.0
3+
Fixed: GITHUB-3022: Remove deprecated JUnit related support in TestNG (Krishnan Mahadevan)
24

35
7.9.0
46
Fixed: GITHUB-2019: Total thread count in testng parallel tests with dataproviders (Krishnan Mahadevan)

Diff for: settings.gradle.kts

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ include(":testng-core")
2727
include(":testng-core-api")
2828
include(":testng-reflection-utils")
2929
include(":testng-runner-api")
30-
include(":testng-runner-junit4")
3130
include(":testng-test-kit")
3231
include(":testng-test-osgi")
3332

Diff for: testng-ant/src/main/java/org/testng/TestNGAntTask.java

-2
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,6 @@ public void execute() throws BuildException {
560560

561561
protected List<String> createArguments() {
562562
List<String> argv = Lists.newArrayList();
563-
addBooleanIfTrue(argv, CommandLineArgs.JUNIT, mode == Mode.junit);
564-
addBooleanIfTrue(argv, CommandLineArgs.MIXED, mode == Mode.mixed);
565563
addBooleanIfTrue(
566564
argv, CommandLineArgs.SKIP_FAILED_INVOCATION_COUNTS, m_skipFailedInvocationCounts);
567565
addIntegerIfNotNull(argv, CommandLineArgs.LOG, m_verbose);

Diff for: testng-bom/testng-bom-build.gradle.kts

-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ dependencies {
1414
api(projects.testngCore)
1515
api(projects.testngReflectionUtils)
1616
api(projects.testngRunnerApi)
17-
api(projects.testngRunnerJunit4)
1817
}
1918
}

Diff for: testng-core-api/src/main/java/org/testng/xml/DefaultXmlWeaver.java

-7
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ public String asXml(XmlSuite xmlSuite) {
6868
if (isStringNotEmpty(xmlSuite.getTimeOut())) {
6969
p.setProperty("time-out", xmlSuite.getTimeOut());
7070
}
71-
if (!DEFAULT_JUNIT.equals(xmlSuite.isJUnit())) {
72-
p.setProperty(
73-
"junit",
74-
xmlSuite.isJUnit() != null ? xmlSuite.isJUnit().toString() : "false"); // TESTNG-141
75-
}
7671
XmlUtils.setProperty(
7772
p,
7873
"skipfailedinvocationcounts",
@@ -174,8 +169,6 @@ public String asXml(XmlTest xmlTest, String indent) {
174169
xsb.setDefaultComment(defaultComment);
175170
Properties p = new Properties();
176171
p.setProperty("name", xmlTest.getName());
177-
XmlUtils.setProperty(
178-
p, "junit", Boolean.toString(xmlTest.isJUnit()), XmlSuite.DEFAULT_JUNIT.toString());
179172
XmlUtils.setProperty(
180173
p, "parallel", xmlTest.getParallel().toString(), XmlSuite.DEFAULT_PARALLEL.toString());
181174
XmlUtils.setProperty(

Diff for: testng-core-api/src/main/java/org/testng/xml/XmlSuite.java

-33
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ public String toString() {
131131

132132
private FailurePolicy m_configFailurePolicy = DEFAULT_CONFIG_FAILURE_POLICY;
133133

134-
/** JUnit compatibility flag. */
135-
public static final Boolean DEFAULT_JUNIT = Boolean.FALSE;
136-
137-
private Boolean m_isJUnit = DEFAULT_JUNIT;
138-
139134
/** Mixed mode flag. */
140135
public static final Boolean DEFAULT_MIXED = Boolean.FALSE;
141136

@@ -457,25 +452,6 @@ public void setThreadCount(int threadCount) {
457452
m_threadCount = threadCount;
458453
}
459454

460-
/** @return The JUnit compatibility flag. */
461-
public Boolean isJUnit() {
462-
return m_isJUnit;
463-
}
464-
465-
/**
466-
* Sets the JUnit compatibility flag.
467-
*
468-
* @param isJUnit The JUnit compatibility flag.
469-
*/
470-
public void setJUnit(Boolean isJUnit) {
471-
m_isJUnit = isJUnit;
472-
}
473-
474-
// For YAML
475-
public void setJunit(Boolean j) {
476-
setJUnit(j);
477-
}
478-
479455
public Boolean skipFailedInvocationCounts() {
480456
return m_skipFailedInvocationCounts;
481457
}
@@ -593,7 +569,6 @@ public XmlSuite shallowCopy() {
593569
result.setVerbose(getVerbose());
594570
result.setXmlPackages(getXmlPackages());
595571
result.setMethodSelectors(getMethodSelectors());
596-
result.setJUnit(isJUnit()); // TESTNG-141
597572
result.setSkipFailedInvocationCounts(skipFailedInvocationCounts());
598573
result.setObjectFactoryClass(getObjectFactoryClass());
599574
result.setAllowReturnValues(getAllowReturnValues());
@@ -699,7 +674,6 @@ public int hashCode() {
699674
prime * result + ((m_configFailurePolicy == null) ? 0 : m_configFailurePolicy.hashCode());
700675
result = prime * result + m_dataProviderThreadCount;
701676
result = prime * result + ((m_fileName == null) ? 0 : m_fileName.hashCode());
702-
result = prime * result + ((m_isJUnit == null) ? 0 : m_isJUnit.hashCode());
703677
result = prime * result + ((m_listeners == null) ? 0 : m_listeners.hashCode());
704678

705679
result = prime * result + ((m_methodSelectors == null) ? 0 : m_methodSelectors.hashCode());
@@ -749,13 +723,6 @@ public boolean equals(Object obj) {
749723
if (m_dataProviderThreadCount != other.m_dataProviderThreadCount) {
750724
return f();
751725
}
752-
if (m_isJUnit == null) {
753-
if (other.m_isJUnit != null) {
754-
return f();
755-
}
756-
} else if (!m_isJUnit.equals(other.m_isJUnit)) {
757-
return f();
758-
}
759726
if (m_listeners == null) {
760727
if (other.m_listeners != null) {
761728
return f();

Diff for: testng-core-api/src/main/java/org/testng/xml/XmlTest.java

-27
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public class XmlTest implements Cloneable {
1313
private XmlSuite m_suite;
1414
private String m_name;
1515
private Integer m_verbose = XmlSuite.DEFAULT_VERBOSE;
16-
private Boolean m_isJUnit = XmlSuite.DEFAULT_JUNIT;
1716
private int m_threadCount = -1;
1817

1918
private List<XmlClass> m_xmlClasses = Lists.newArrayList();
@@ -239,26 +238,6 @@ public void setGroupByInstances(boolean f) {
239238
m_groupByInstances = f;
240239
}
241240

242-
/** @return Returns the isJUnit. */
243-
public boolean isJUnit() {
244-
Boolean result = m_isJUnit;
245-
if (null == result || XmlSuite.DEFAULT_JUNIT.equals(result)) {
246-
result = getSuite().isJUnit();
247-
}
248-
249-
return result;
250-
}
251-
252-
/** @param isJUnit The isJUnit to set. */
253-
public void setJUnit(boolean isJUnit) {
254-
m_isJUnit = isJUnit;
255-
}
256-
257-
// For YAML
258-
public void setJunit(boolean isJUnit) {
259-
setJUnit(isJUnit);
260-
}
261-
262241
public void setSkipFailedInvocationCounts(boolean skip) {
263242
m_skipFailedInvocationCounts = skip;
264243
}
@@ -414,7 +393,6 @@ public Object clone() {
414393
result.setName(getName());
415394
result.setIncludedGroups(getIncludedGroups());
416395
result.setExcludedGroups(getExcludedGroups());
417-
result.setJUnit(isJUnit());
418396
result.setParallel(getParallel());
419397
result.setThreadCount(getThreadCount());
420398
result.setVerbose(getVerbose());
@@ -512,7 +490,6 @@ public int hashCode() {
512490
+ ((m_xmlGroups == null || m_xmlGroups.getRun() == null)
513491
? 0
514492
: m_xmlGroups.getRun().getIncludes().hashCode());
515-
result = prime * result + ((m_isJUnit == null) ? 0 : m_isJUnit.hashCode());
516493
result = prime * result + ((m_xmlGroups == null) ? 0 : m_xmlGroups.getDefines().hashCode());
517494
result = prime * result + ((m_methodSelectors == null) ? 0 : m_methodSelectors.hashCode());
518495
result = prime * result + ((m_name == null) ? 0 : m_name.hashCode());
@@ -564,10 +541,6 @@ public boolean equals(Object obj) {
564541
if (other.m_failedInvocationNumbers != null) return XmlSuite.f();
565542
} else if (!m_failedInvocationNumbers.equals(other.m_failedInvocationNumbers))
566543
return XmlSuite.f();
567-
if (m_isJUnit == null) {
568-
if (other.m_isJUnit != null && !other.m_isJUnit.equals(XmlSuite.DEFAULT_JUNIT))
569-
return XmlSuite.f();
570-
} else if (!m_isJUnit.equals(other.m_isJUnit)) return XmlSuite.f();
571544
if (m_methodSelectors == null) {
572545
if (other.m_methodSelectors != null) return XmlSuite.f();
573546
} else if (!m_methodSelectors.equals(other.m_methodSelectors)) return XmlSuite.f();

Diff for: testng-core/src/main/java/org/testng/CommandLineArgs.java

-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ public class CommandLineArgs {
3636
@Parameter(names = OUTPUT_DIRECTORY, description = "Output directory")
3737
public String outputDirectory;
3838

39-
public static final String JUNIT = "-junit";
40-
41-
@Parameter(names = JUNIT, description = "JUnit mode")
42-
public Boolean junit = Boolean.FALSE;
43-
4439
public static final String MIXED = "-mixed";
4540

4641
@Parameter(

Diff for: testng-core/src/main/java/org/testng/TestNG.java

-42
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.testng.internal.objects.pojo.BasicAttributes;
4949
import org.testng.internal.objects.pojo.CreationAttributes;
5050
import org.testng.internal.thread.graph.SuiteWorkerFactory;
51-
import org.testng.junit.JUnitTestFinder;
5251
import org.testng.log4testng.Logger;
5352
import org.testng.reporters.EmailableReporter2;
5453
import org.testng.reporters.FailedReporter;
@@ -129,12 +128,8 @@ public class TestNG {
129128
protected List<XmlSuite> m_suites = Lists.newArrayList();
130129
private List<XmlSuite> m_cmdlineSuites;
131130
private String m_outputDir = DEFAULT_OUTPUTDIR;
132-
133131
private String[] m_includedGroups;
134132
private String[] m_excludedGroups;
135-
136-
private Boolean m_isJUnit = XmlSuite.DEFAULT_JUNIT;
137-
private Boolean m_isMixed = XmlSuite.DEFAULT_MIXED;
138133
protected boolean m_useDefaultListeners = true;
139134
private boolean m_failIfAllTestsSkipped = false;
140135
private final List<String> m_listenersToSkipFromBeingWiredIn = new ArrayList<>();
@@ -545,11 +540,6 @@ private List<XmlSuite> createCommandLineSuitesForClasses(Class[] classes) {
545540
if (test != null) {
546541
suiteName = defaultIfStringEmpty(test.getSuiteName(), suiteName);
547542
testName = defaultIfStringEmpty(test.getTestName(), testName);
548-
} else {
549-
if (m_isMixed && JUnitTestFinder.isJUnitTest(c)) {
550-
isJUnit = true;
551-
testName = c.getName();
552-
}
553543
}
554544
XmlSuite xmlSuite = suites.get(suiteName);
555545
if (xmlSuite == null) {
@@ -572,7 +562,6 @@ private List<XmlSuite> createCommandLineSuitesForClasses(Class[] classes) {
572562
if (xmlTest == null) {
573563
xmlTest = new XmlTest(xmlSuite);
574564
xmlTest.setName(testName);
575-
xmlTest.setJUnit(isJUnit);
576565
}
577566

578567
xmlTest.getXmlClasses().add(xmlClasses[i]);
@@ -1329,10 +1318,6 @@ private void populateSuiteGraph(
13291318
* @param xmlSuite Xml Suite (and its children) for which {@code SuiteRunner}s are created
13301319
*/
13311320
private void createSuiteRunners(SuiteRunnerMap suiteRunnerMap /* OUT */, XmlSuite xmlSuite) {
1332-
if (null != m_isJUnit && !m_isJUnit.equals(XmlSuite.DEFAULT_JUNIT)) {
1333-
xmlSuite.setJUnit(m_isJUnit);
1334-
}
1335-
13361321
// If the skip flag was invoked on the command line, it
13371322
// takes precedence
13381323
if (null != m_skipFailedInvocationCounts) {
@@ -1526,8 +1511,6 @@ protected void configure(CommandLineArgs cla) {
15261511
setExcludedGroups(cla.excludedGroups);
15271512
setTestJar(cla.testJar);
15281513
setXmlPathInJar(cla.xmlPathInJar);
1529-
setJUnit(cla.junit);
1530-
setMixed(cla.mixed);
15311514
setSkipFailedInvocationCounts(cla.skipFailedInvocationCounts);
15321515
toggleFailureIfAllTestsWereSkipped(cla.failIfAllTestsSkipped);
15331516
setListenersToSkipFromBeingWiredInViaServiceLoaders(cla.spiListenersToSkip.split(","));
@@ -1695,7 +1678,6 @@ public void configure(Map cmdLineArgs) {
16951678
result.excludedGroups = (String) cmdLineArgs.get(CommandLineArgs.EXCLUDED_GROUPS);
16961679
result.testJar = (String) cmdLineArgs.get(CommandLineArgs.TEST_JAR);
16971680
result.xmlPathInJar = (String) cmdLineArgs.get(CommandLineArgs.XML_PATH_IN_JAR);
1698-
result.junit = (Boolean) cmdLineArgs.get(CommandLineArgs.JUNIT);
16991681
result.mixed = (Boolean) cmdLineArgs.get(CommandLineArgs.MIXED);
17001682
Object tmpValue = cmdLineArgs.get(CommandLineArgs.INCLUDE_ALL_DATA_DRIVEN_TESTS_WHEN_SKIPPING);
17011683
if (tmpValue != null) {
@@ -1825,23 +1807,6 @@ private IReporter newReporterInstance(ReporterConfig config) {
18251807
return reporter;
18261808
}
18271809

1828-
/**
1829-
* Specify if this run should be made in JUnit mode
1830-
*
1831-
* @param isJUnit - Specify if this run should be made in JUnit mode
1832-
*/
1833-
public void setJUnit(Boolean isJUnit) {
1834-
m_isJUnit = isJUnit;
1835-
}
1836-
1837-
/** @param isMixed Specify if this run should be made in mixed mode */
1838-
public void setMixed(Boolean isMixed) {
1839-
if (isMixed == null) {
1840-
return;
1841-
}
1842-
m_isMixed = isMixed;
1843-
}
1844-
18451810
/**
18461811
* Double check that the command line parameters are valid.
18471812
*
@@ -1870,13 +1835,6 @@ protected static void validateCommandLineParameters(CommandLineArgs args) {
18701835
&& (testNgXml == null || testNgXml.isEmpty())) {
18711836
throw new ParameterException("Groups option should be used with testclass option");
18721837
}
1873-
1874-
Boolean junit = args.junit;
1875-
Boolean mixed = args.mixed;
1876-
if (junit && mixed) {
1877-
throw new ParameterException(
1878-
CommandLineArgs.MIXED + " can't be combined with " + CommandLineArgs.JUNIT);
1879-
}
18801838
}
18811839

18821840
/** @return true if at least one test failed. */

0 commit comments

Comments
 (0)