Skip to content

Commit

Permalink
Abort for invalid combinations
Browse files Browse the repository at this point in the history
GraphThreadPoolExecutor will NOT work if user is
trying to use a shared thread pool for just their
data driven tests (or) for all tests (both regular and data driven)
.

So if these combinations are found, abort execution.
  • Loading branch information
krmahadevan committed Dec 21, 2023
1 parent d01a4f1 commit 42b5239
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions testng-core/src/main/java/org/testng/TestNG.java
Original file line number Diff line number Diff line change
Expand Up @@ -1209,9 +1209,11 @@ public List<ISuite> runSuitesLocally() {
// Create a map with XmlSuite as key and corresponding SuiteRunner as value
for (XmlSuite xmlSuite : m_suites) {
if (m_configuration.isShareThreadPoolForDataProviders()) {
abortIfUsingGraphThreadPoolExecutor("Shared thread-pool for data providers");
xmlSuite.setShareThreadPoolForDataProviders(true);
}
if (m_configuration.useGlobalThreadPool()) {
abortIfUsingGraphThreadPoolExecutor("Global thread-pool");
xmlSuite.shouldUseGlobalThreadPool(true);
}
createSuiteRunners(suiteRunnerMap, xmlSuite);
Expand Down Expand Up @@ -1262,6 +1264,13 @@ private static void error(String s) {
LOGGER.error(s);
}

private static void abortIfUsingGraphThreadPoolExecutor(String prefix) {
if (RuntimeBehavior.favourCustomThreadPoolExecutor()) {
throw new UnsupportedOperationException(
prefix + " is NOT COMPATIBLE with TestNG's custom thread pool executor");
}
}

/**
* @return the verbose level, checking in order: the verbose level on the suite, the verbose level
* on the TestNG object, or 1.
Expand Down

0 comments on commit 42b5239

Please sign in to comment.