Skip to content

Commit 42b5239

Browse files
committed
Abort for invalid combinations
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.
1 parent d01a4f1 commit 42b5239

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

testng-core/src/main/java/org/testng/TestNG.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,9 +1209,11 @@ public List<ISuite> runSuitesLocally() {
12091209
// Create a map with XmlSuite as key and corresponding SuiteRunner as value
12101210
for (XmlSuite xmlSuite : m_suites) {
12111211
if (m_configuration.isShareThreadPoolForDataProviders()) {
1212+
abortIfUsingGraphThreadPoolExecutor("Shared thread-pool for data providers");
12121213
xmlSuite.setShareThreadPoolForDataProviders(true);
12131214
}
12141215
if (m_configuration.useGlobalThreadPool()) {
1216+
abortIfUsingGraphThreadPoolExecutor("Global thread-pool");
12151217
xmlSuite.shouldUseGlobalThreadPool(true);
12161218
}
12171219
createSuiteRunners(suiteRunnerMap, xmlSuite);
@@ -1262,6 +1264,13 @@ private static void error(String s) {
12621264
LOGGER.error(s);
12631265
}
12641266

1267+
private static void abortIfUsingGraphThreadPoolExecutor(String prefix) {
1268+
if (RuntimeBehavior.favourCustomThreadPoolExecutor()) {
1269+
throw new UnsupportedOperationException(
1270+
prefix + " is NOT COMPATIBLE with TestNG's custom thread pool executor");
1271+
}
1272+
}
1273+
12651274
/**
12661275
* @return the verbose level, checking in order: the verbose level on the suite, the verbose level
12671276
* on the TestNG object, or 1.

0 commit comments

Comments
 (0)