Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated JUnit related support in TestNG #3023

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Current
7.10.0
Fixed: GITHUB-3022: Remove deprecated JUnit related support in TestNG (Krishnan Mahadevan)

7.9.0
Fixed: GITHUB-2019: Total thread count in testng parallel tests with dataproviders (Krishnan Mahadevan)
Expand Down
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ include(":testng-core")
include(":testng-core-api")
include(":testng-reflection-utils")
include(":testng-runner-api")
include(":testng-runner-junit4")
include(":testng-test-kit")
include(":testng-test-osgi")

Expand Down
2 changes: 0 additions & 2 deletions testng-ant/src/main/java/org/testng/TestNGAntTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,6 @@ public void execute() throws BuildException {

protected List<String> createArguments() {
List<String> argv = Lists.newArrayList();
addBooleanIfTrue(argv, CommandLineArgs.JUNIT, mode == Mode.junit);
addBooleanIfTrue(argv, CommandLineArgs.MIXED, mode == Mode.mixed);
addBooleanIfTrue(
argv, CommandLineArgs.SKIP_FAILED_INVOCATION_COUNTS, m_skipFailedInvocationCounts);
addIntegerIfNotNull(argv, CommandLineArgs.LOG, m_verbose);
Expand Down
1 change: 0 additions & 1 deletion testng-bom/testng-bom-build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ dependencies {
api(projects.testngCore)
api(projects.testngReflectionUtils)
api(projects.testngRunnerApi)
api(projects.testngRunnerJunit4)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ public String asXml(XmlSuite xmlSuite) {
if (isStringNotEmpty(xmlSuite.getTimeOut())) {
p.setProperty("time-out", xmlSuite.getTimeOut());
}
if (!DEFAULT_JUNIT.equals(xmlSuite.isJUnit())) {
p.setProperty(
"junit",
xmlSuite.isJUnit() != null ? xmlSuite.isJUnit().toString() : "false"); // TESTNG-141
}
XmlUtils.setProperty(
p,
"skipfailedinvocationcounts",
Expand Down Expand Up @@ -174,8 +169,6 @@ public String asXml(XmlTest xmlTest, String indent) {
xsb.setDefaultComment(defaultComment);
Properties p = new Properties();
p.setProperty("name", xmlTest.getName());
XmlUtils.setProperty(
p, "junit", Boolean.toString(xmlTest.isJUnit()), XmlSuite.DEFAULT_JUNIT.toString());
XmlUtils.setProperty(
p, "parallel", xmlTest.getParallel().toString(), XmlSuite.DEFAULT_PARALLEL.toString());
XmlUtils.setProperty(
Expand Down
33 changes: 0 additions & 33 deletions testng-core-api/src/main/java/org/testng/xml/XmlSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,6 @@ public String toString() {

private FailurePolicy m_configFailurePolicy = DEFAULT_CONFIG_FAILURE_POLICY;

/** JUnit compatibility flag. */
public static final Boolean DEFAULT_JUNIT = Boolean.FALSE;

private Boolean m_isJUnit = DEFAULT_JUNIT;

/** Mixed mode flag. */
public static final Boolean DEFAULT_MIXED = Boolean.FALSE;

Expand Down Expand Up @@ -457,25 +452,6 @@ public void setThreadCount(int threadCount) {
m_threadCount = threadCount;
}

/** @return The JUnit compatibility flag. */
public Boolean isJUnit() {
return m_isJUnit;
}

/**
* Sets the JUnit compatibility flag.
*
* @param isJUnit The JUnit compatibility flag.
*/
public void setJUnit(Boolean isJUnit) {
m_isJUnit = isJUnit;
}

// For YAML
public void setJunit(Boolean j) {
setJUnit(j);
}

public Boolean skipFailedInvocationCounts() {
return m_skipFailedInvocationCounts;
}
Expand Down Expand Up @@ -593,7 +569,6 @@ public XmlSuite shallowCopy() {
result.setVerbose(getVerbose());
result.setXmlPackages(getXmlPackages());
result.setMethodSelectors(getMethodSelectors());
result.setJUnit(isJUnit()); // TESTNG-141
result.setSkipFailedInvocationCounts(skipFailedInvocationCounts());
result.setObjectFactoryClass(getObjectFactoryClass());
result.setAllowReturnValues(getAllowReturnValues());
Expand Down Expand Up @@ -699,7 +674,6 @@ public int hashCode() {
prime * result + ((m_configFailurePolicy == null) ? 0 : m_configFailurePolicy.hashCode());
result = prime * result + m_dataProviderThreadCount;
result = prime * result + ((m_fileName == null) ? 0 : m_fileName.hashCode());
result = prime * result + ((m_isJUnit == null) ? 0 : m_isJUnit.hashCode());
result = prime * result + ((m_listeners == null) ? 0 : m_listeners.hashCode());

result = prime * result + ((m_methodSelectors == null) ? 0 : m_methodSelectors.hashCode());
Expand Down Expand Up @@ -749,13 +723,6 @@ public boolean equals(Object obj) {
if (m_dataProviderThreadCount != other.m_dataProviderThreadCount) {
return f();
}
if (m_isJUnit == null) {
if (other.m_isJUnit != null) {
return f();
}
} else if (!m_isJUnit.equals(other.m_isJUnit)) {
return f();
}
if (m_listeners == null) {
if (other.m_listeners != null) {
return f();
Expand Down
27 changes: 0 additions & 27 deletions testng-core-api/src/main/java/org/testng/xml/XmlTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class XmlTest implements Cloneable {
private XmlSuite m_suite;
private String m_name;
private Integer m_verbose = XmlSuite.DEFAULT_VERBOSE;
private Boolean m_isJUnit = XmlSuite.DEFAULT_JUNIT;
private int m_threadCount = -1;

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

/** @return Returns the isJUnit. */
public boolean isJUnit() {
Boolean result = m_isJUnit;
if (null == result || XmlSuite.DEFAULT_JUNIT.equals(result)) {
result = getSuite().isJUnit();
}

return result;
}

/** @param isJUnit The isJUnit to set. */
public void setJUnit(boolean isJUnit) {
m_isJUnit = isJUnit;
}

// For YAML
public void setJunit(boolean isJUnit) {
setJUnit(isJUnit);
}

public void setSkipFailedInvocationCounts(boolean skip) {
m_skipFailedInvocationCounts = skip;
}
Expand Down Expand Up @@ -414,7 +393,6 @@ public Object clone() {
result.setName(getName());
result.setIncludedGroups(getIncludedGroups());
result.setExcludedGroups(getExcludedGroups());
result.setJUnit(isJUnit());
result.setParallel(getParallel());
result.setThreadCount(getThreadCount());
result.setVerbose(getVerbose());
Expand Down Expand Up @@ -512,7 +490,6 @@ public int hashCode() {
+ ((m_xmlGroups == null || m_xmlGroups.getRun() == null)
? 0
: m_xmlGroups.getRun().getIncludes().hashCode());
result = prime * result + ((m_isJUnit == null) ? 0 : m_isJUnit.hashCode());
result = prime * result + ((m_xmlGroups == null) ? 0 : m_xmlGroups.getDefines().hashCode());
result = prime * result + ((m_methodSelectors == null) ? 0 : m_methodSelectors.hashCode());
result = prime * result + ((m_name == null) ? 0 : m_name.hashCode());
Expand Down Expand Up @@ -564,10 +541,6 @@ public boolean equals(Object obj) {
if (other.m_failedInvocationNumbers != null) return XmlSuite.f();
} else if (!m_failedInvocationNumbers.equals(other.m_failedInvocationNumbers))
return XmlSuite.f();
if (m_isJUnit == null) {
if (other.m_isJUnit != null && !other.m_isJUnit.equals(XmlSuite.DEFAULT_JUNIT))
return XmlSuite.f();
} else if (!m_isJUnit.equals(other.m_isJUnit)) return XmlSuite.f();
if (m_methodSelectors == null) {
if (other.m_methodSelectors != null) return XmlSuite.f();
} else if (!m_methodSelectors.equals(other.m_methodSelectors)) return XmlSuite.f();
Expand Down
5 changes: 0 additions & 5 deletions testng-core/src/main/java/org/testng/CommandLineArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ public class CommandLineArgs {
@Parameter(names = OUTPUT_DIRECTORY, description = "Output directory")
public String outputDirectory;

public static final String JUNIT = "-junit";

@Parameter(names = JUNIT, description = "JUnit mode")
public Boolean junit = Boolean.FALSE;

public static final String MIXED = "-mixed";

@Parameter(
Expand Down
42 changes: 0 additions & 42 deletions testng-core/src/main/java/org/testng/TestNG.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.testng.internal.objects.pojo.BasicAttributes;
import org.testng.internal.objects.pojo.CreationAttributes;
import org.testng.internal.thread.graph.SuiteWorkerFactory;
import org.testng.junit.JUnitTestFinder;
import org.testng.log4testng.Logger;
import org.testng.reporters.EmailableReporter2;
import org.testng.reporters.FailedReporter;
Expand Down Expand Up @@ -129,12 +128,8 @@ public class TestNG {
protected List<XmlSuite> m_suites = Lists.newArrayList();
private List<XmlSuite> m_cmdlineSuites;
private String m_outputDir = DEFAULT_OUTPUTDIR;

private String[] m_includedGroups;
private String[] m_excludedGroups;

private Boolean m_isJUnit = XmlSuite.DEFAULT_JUNIT;
private Boolean m_isMixed = XmlSuite.DEFAULT_MIXED;
protected boolean m_useDefaultListeners = true;
private boolean m_failIfAllTestsSkipped = false;
private final List<String> m_listenersToSkipFromBeingWiredIn = new ArrayList<>();
Expand Down Expand Up @@ -545,11 +540,6 @@ private List<XmlSuite> createCommandLineSuitesForClasses(Class[] classes) {
if (test != null) {
suiteName = defaultIfStringEmpty(test.getSuiteName(), suiteName);
testName = defaultIfStringEmpty(test.getTestName(), testName);
} else {
if (m_isMixed && JUnitTestFinder.isJUnitTest(c)) {
isJUnit = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isJUnit declaration should be removed too

testName = c.getName();
}
}
XmlSuite xmlSuite = suites.get(suiteName);
if (xmlSuite == null) {
Expand All @@ -572,7 +562,6 @@ private List<XmlSuite> createCommandLineSuitesForClasses(Class[] classes) {
if (xmlTest == null) {
xmlTest = new XmlTest(xmlSuite);
xmlTest.setName(testName);
xmlTest.setJUnit(isJUnit);
}

xmlTest.getXmlClasses().add(xmlClasses[i]);
Expand Down Expand Up @@ -1329,10 +1318,6 @@ private void populateSuiteGraph(
* @param xmlSuite Xml Suite (and its children) for which {@code SuiteRunner}s are created
*/
private void createSuiteRunners(SuiteRunnerMap suiteRunnerMap /* OUT */, XmlSuite xmlSuite) {
if (null != m_isJUnit && !m_isJUnit.equals(XmlSuite.DEFAULT_JUNIT)) {
xmlSuite.setJUnit(m_isJUnit);
}

// If the skip flag was invoked on the command line, it
// takes precedence
if (null != m_skipFailedInvocationCounts) {
Expand Down Expand Up @@ -1526,8 +1511,6 @@ protected void configure(CommandLineArgs cla) {
setExcludedGroups(cla.excludedGroups);
setTestJar(cla.testJar);
setXmlPathInJar(cla.xmlPathInJar);
setJUnit(cla.junit);
setMixed(cla.mixed);
setSkipFailedInvocationCounts(cla.skipFailedInvocationCounts);
toggleFailureIfAllTestsWereSkipped(cla.failIfAllTestsSkipped);
setListenersToSkipFromBeingWiredInViaServiceLoaders(cla.spiListenersToSkip.split(","));
Expand Down Expand Up @@ -1695,7 +1678,6 @@ public void configure(Map cmdLineArgs) {
result.excludedGroups = (String) cmdLineArgs.get(CommandLineArgs.EXCLUDED_GROUPS);
result.testJar = (String) cmdLineArgs.get(CommandLineArgs.TEST_JAR);
result.xmlPathInJar = (String) cmdLineArgs.get(CommandLineArgs.XML_PATH_IN_JAR);
result.junit = (Boolean) cmdLineArgs.get(CommandLineArgs.JUNIT);
result.mixed = (Boolean) cmdLineArgs.get(CommandLineArgs.MIXED);
Object tmpValue = cmdLineArgs.get(CommandLineArgs.INCLUDE_ALL_DATA_DRIVEN_TESTS_WHEN_SKIPPING);
if (tmpValue != null) {
Expand Down Expand Up @@ -1825,23 +1807,6 @@ private IReporter newReporterInstance(ReporterConfig config) {
return reporter;
}

/**
* Specify if this run should be made in JUnit mode
*
* @param isJUnit - Specify if this run should be made in JUnit mode
*/
public void setJUnit(Boolean isJUnit) {
m_isJUnit = isJUnit;
}

/** @param isMixed Specify if this run should be made in mixed mode */
public void setMixed(Boolean isMixed) {
if (isMixed == null) {
return;
}
m_isMixed = isMixed;
}

/**
* Double check that the command line parameters are valid.
*
Expand Down Expand Up @@ -1870,13 +1835,6 @@ protected static void validateCommandLineParameters(CommandLineArgs args) {
&& (testNgXml == null || testNgXml.isEmpty())) {
throw new ParameterException("Groups option should be used with testclass option");
}

Boolean junit = args.junit;
Boolean mixed = args.mixed;
if (junit && mixed) {
throw new ParameterException(
CommandLineArgs.MIXED + " can't be combined with " + CommandLineArgs.JUNIT);
}
}

/** @return true if at least one test failed. */
Expand Down
Loading
Loading