For a documented, build-integrated solution, configure TestNG in testng.xml (or Maven Surefire) with an explicit parallel mode and thread-count. A custom Excel allocator cannot be judged fairly until its work-item mapping, worker limits, ordering rules, and thread-safety behavior are known. The guide below shows the complete TestNG setup and a practical framework for comparing it with that allocator.
What parallel execution changes
Sequential execution gives one test flow the process at a time. Parallel execution lets multiple eligible units run concurrently, reducing elapsed time when the tests are independent and the environment can support the load. Concurrency also exposes shared-state bugs: tests that reuse accounts, files, browser sessions, ports, database rows, or static variables can interfere with one another when they were safe only because they previously ran in order.
As an Amazon Associate I earn from qualifying purchases.
TestNG does not create parallel threads automatically. A suite must select a parallel mode and set a thread limit. The mode defines the boundary that TestNG keeps together; thread-count defines the maximum number of workers available for that execution. A larger number is not a speed guarantee, because the test system may be limited by browsers, databases, CPU, memory, network capacity, or external rate limits.
TestNG’s four suite-level parallel modes
Set the mode on the top-level <suite> element. The choice should follow the smallest unit that can safely run independently.
| Mode | What TestNG schedules concurrently | Boundary it preserves | Typical reason to choose it |
|---|---|---|---|
methods |
Test methods | Each eligible method can run in its own thread; dependency ordering remains respected | Methods are genuinely independent and fixtures are thread-safe |
tests |
XML <test> sections |
Methods inside one XML <test> stay on the same thread |
Grouped classes share state or are not safe to interleave, while groups can run concurrently |
classes |
Test classes | Methods in one class run on the same thread; different classes can use different threads | A class owns state that must not be touched concurrently, but classes are independent |
instances |
Test instances | Methods belonging to one instance remain on one thread | Separate object instances represent isolated test contexts |
These are grouping semantics, not priorities. For example, parallel="methods" does not override a declared dependency: dependent methods still follow their specified order. Conversely, selecting classes does not make static fields, singletons, or external resources safe; it only keeps methods from the same class on one worker.
Minimal testng.xml configuration
Start with a suite-level declaration. The following example uses method parallelism and a five-thread ceiling as an illustration, not as a universal recommendation.
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.1.dtd">
<suite name="Example" parallel="methods" thread-count="5">
<test name="Tests">
<classes>
<class name="example.ExampleTest"/>
</classes>
</test>
</suite>
- Create or open the suite XML that your build actually executes.
- Add the TestNG 1.1 DTD declaration shown above when using the current suite attributes documented for TestNG 7.9.0 and later.
- Choose exactly one suite-level
parallelvalue:methods,tests,classes, orinstances. - Set
thread-countto a deliberate maximum. Begin with a value your test environment can sustain, then measure runtime, failures, queueing, and resource saturation. - Run the suite through the same command used in continuous integration. An IDE run, Maven run, and a different XML file can silently use different settings.
If parallel is omitted, TestNG does not use parallel threads by default. If a suite appears to ignore your setting, first verify that the runner loaded this XML file rather than an annotation-only or IDE-generated suite.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallChoosing the right mode for real test structure
Use methods only when method-level isolation is real
Method parallelism offers the finest scheduling granularity. It is useful when every method creates or receives its own data and does not mutate a shared fixture. A common failure pattern is a class-level driver, mutable static configuration, or a shared login account: two methods then navigate or update the same resource at once. Replace shared fields with per-invocation objects, unique test data, or a synchronization strategy before selecting this mode.
Use tests to preserve an XML group boundary
With parallel="tests", all methods in one XML <test> remain on one thread, while separate <test> elements may run on separate threads. This is a practical compromise for grouped, non-thread-safe classes. Put tests that share a browser session, account, or serialized fixture in one XML group, and place independent groups in separate <test> elements.
Use classes when class ownership is the safe boundary
parallel="classes" keeps methods in each class on one thread and allows different classes to execute concurrently. It is appropriate when setup and teardown are class-scoped and safe within one class, but classes do not share mutable external state. Check inherited fixtures and static utilities; a class boundary cannot isolate a globally shared object.
Use instances for object-level isolation
Instance mode is useful when a data-driven or factory-created object represents a complete test context. Methods for one instance stay together, while different instances can be assigned independently. Confirm that the factory really creates independent state; multiple instances that point to the same account or file are not isolated merely because they are different Java objects.
How to set and tune thread-count
thread-count is the maximum worker count for the selected suite parallelism. It is not a target number of simultaneously active tests and does not promise a proportional runtime reduction. TestNG may have fewer runnable units than the limit, and tests can spend time waiting on I/O or dependencies.
- Start below the environment’s hard limits. Count available browser sessions, service licenses, database connections, CPU cores, memory, and container quotas.
- Measure failure rate as well as duration. A faster run with intermittent collisions, timeouts, or throttling is not a successful optimization.
- Increase in small steps. Compare the same suite, data set, and machine conditions at each step so that the effect of concurrency is visible.
- Keep test data unique. Distinct rows, users, files, and ports prevent false failures that can otherwise look like a thread-count problem.
- Record the effective configuration. Log the suite file, parallel mode, thread count, TestNG version, and build-plugin version with each CI run.
Do not infer a safe value from the illustrative value 5 in the example XML. The correct ceiling is specific to the tests and the system under test.
Parallel data providers and TestNG 7.9.0 controls
Suite parallelism and data-provider parallelism are related but separate controls. A data provider can opt into concurrent invocations with @DataProvider(parallel = true). That setting determines whether the provider’s rows may run in parallel; the available worker pool still needs an appropriate size.
TestNG documentation for version 7.9.0 and later adds suite-level controls for those pools. The current suite declaration must use the testng-1.1.dtd definition for these attributes.
share-thread-pool-for-data-providers="true"shares one pool for data-driven tests in a suite. Its size is controlled bydata-provider-thread-count.use-global-thread-pool="true"shares a pool between regular tests and data-driven tests. In this arrangement,thread-countcontrols the global pool.
Use one pool deliberately. Independent pools can overlap and create more total concurrency than expected, while a global pool can make regular tests wait behind a large data-driven workload. If a suite uses these attributes but runs an older TestNG version or an older DTD declaration, verify version compatibility before diagnosing the behavior as a scheduling bug.
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.1.dtd">
<suite name="DataDriven"
parallel="classes"
thread-count="4"
share-thread-pool-for-data-providers="true"
data-provider-thread-count="4">
<test name="Orders">
<classes>
<class name="example.OrderTest"/>
</classes>
</test>
</suite>
The snippet demonstrates the attributes; choose values and combinations only after checking the TestNG version used by the project and confirming that the test data can be processed concurrently.
Maven Surefire configuration
Maven Surefire can express TestNG parallel settings in the plugin configuration instead of, or alongside, suite XML. The cited Surefire example targets version 3.2.5, so match its syntax to the version declared in your own pom.xml.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<configuration>
<parallel>methods</parallel>
<threadCount>5</threadCount>
</configuration>
</plugin>
Decide which layer is authoritative. Maintaining a parallel mode in both Surefire and testng.xml can create conflicting expectations, especially when different profiles select different suite files. Check the effective Maven configuration and the actual TestNG report to confirm what the run used.
Recommended Free Tools
Rank #4
A verification and troubleshooting checklist
When tests still run sequentially
- Confirm that the executed suite contains a
parallelattribute and a positivethread-count. - Confirm that the build is loading that suite, not another XML file or an annotation-only run.
- Check the Maven profile and Surefire version if the command is launched through Maven.
- Ensure the suite has enough independent methods, classes, tests, or instances to occupy more than one worker.
When failures appear only in parallel runs
- Look for static fields, singleton services, shared drivers, mutable class fixtures, reused files, and duplicate test accounts.
- Inspect dependencies and ordering. Parallel mode does not permit a dependent method to run before its prerequisite.
- Check teardown code for global cleanup that can delete another worker’s data.
- Reduce
thread-counttemporarily. If the failure disappears, investigate resource contention rather than treating the lower value as the permanent fix.
When data-driven runs overload the system
- Check whether
@DataProvider(parallel = true)is enabled. - Review
data-provider-thread-count, shared-pool settings, and the globalthread-count. - Make sure separate pools are not multiplying total concurrency beyond the database, browser grid, or service limits.
- Use unique input rows or explicit locking for resources that cannot be shared.
What a “custom Excel allocator” must mean before comparison
“Custom Excel allocator” is not a defined TestNG feature or a single standard product. It could mean a spreadsheet that assigns rows to workers, a Java parser that reads an .xlsx file and launches tests, or a scheduler that treats each row as a work item. The title does not identify its file format, algorithm, source repository, version, or mapping from spreadsheet rows to test workers. Therefore, no defensible claim can be made that it is faster, safer, or equivalent to TestNG.
Apache POI documentation describes library configuration, but that does not establish how a particular allocator schedules work. If the allocator reads Excel through POI, the library only handles spreadsheet access; the custom code still determines worker creation, ordering, retries, locking, and failure handling.
Before making a direct comparison, obtain the allocator’s implementation or a precise specification answering these questions:
- Scheduling unit: Is one row a test method, a data-provider invocation, an XML
<test>, a class, an instance, or a custom job? - Concurrency cap: Where is the maximum worker count set? Can separate sheets or queues create independent pools that overlap?
- Grouping and ordering: Can related rows stay together? Are dependencies, priorities, and retries represented?
- Data-driven behavior: Does the allocator call TestNG data providers, generate XML, invoke Java methods directly, or run another executor?
- Thread safety: Are workbook reads, row updates, output files, test fixtures, and external resources protected when workers act concurrently?
- Build integration: Is configuration controlled by TestNG XML, Maven Surefire, a spreadsheet/parser command, or several layers at once?
- Failure semantics: How are a failed row, a crashed worker, a timeout, and a rerun recorded?
Without these answers, the allocator should be treated as an implementation to inspect, not as a documented alternative with known guarantees.
Feature-by-feature comparison framework
| Decision axis | TestNG behavior established by its configuration | What must be verified in the custom allocator |
|---|---|---|
| Work unit | Methods, XML tests, classes, or instances, selected by the suite’s parallel value |
How an Excel row or other allocator-defined item maps to executable work |
| Worker limit | thread-count caps the selected suite pool; data providers can use their documented pool controls |
Where limits are configured and whether multiple pools can overlap |
| Ordering and dependencies | Dependent methods retain their specified order even with method parallelism | Whether dependencies, row order, grouping, and retries are preserved |
| Grouping boundary | tests, classes, and instances preserve their respective same-thread boundaries |
Whether related spreadsheet rows are pinned to one worker or can interleave |
| Data-driven execution | @DataProvider(parallel = true) plus suite-level pool settings from TestNG 7.9.0 documentation |
Whether rows become TestNG invocations or bypass TestNG’s data-provider controls |
| Configuration and build | testng.xml or Maven Surefire; the cited plugin example uses Surefire 3.2.5 |
Which parser, launcher, plugin, and version own the effective configuration |
| Isolation guarantees | TestNG supplies scheduling boundaries, not automatic protection for shared mutable state | What locks, unique data, cleanup rules, and fixture scopes the allocator supplies |
This comparison separates documented scheduler behavior from assumptions. A custom allocator can be excellent, but its advantages must come from its actual implementation and operational evidence rather than from the word “Excel.”
Best Value
Which approach should you choose?
Choose TestNG parallel execution when the tests already fit TestNG’s model
- Your tests are TestNG methods, classes, instances, or data providers.
- You want configuration reviewed as code in
testng.xmlor Maven. - You need documented dependency handling and familiar reports.
- You can establish a safe grouping boundary and control shared resources.
Start with the least aggressive mode that gives useful concurrency. For stateful classes, tests or classes usually provides a clearer boundary than methods. For independent factory-created contexts, instances may preserve isolation while still using multiple workers.
Consider the custom allocator only when its extra model solves a demonstrated need
An Excel-driven layer may be justified if business users must maintain assignments in a workbook, if scheduling units do not map cleanly to TestNG’s boundaries, or if an existing operations process requires spreadsheet-based allocation. Those benefits are conditional: the allocator must specify how it launches TestNG, limits concurrency, records failures, and prevents two workers from consuming the same row or resource.
Do not adopt it merely to obtain parallelism. TestNG already provides suite and data-provider controls. A custom layer adds another parser, configuration source, and failure surface; it should earn that complexity with a requirement that native TestNG configuration cannot satisfy.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →A safe rollout plan
- Inventory shared state. List drivers, accounts, files, ports, database records, static fields, and services touched by the suite.
- Classify tests by safe boundary. Mark each group as method-, class-, instance-, or XML-test-safe, and record dependencies.
- Enable one TestNG mode. Use a small illustrative thread count and run the same suite repeatedly to expose nondeterministic failures.
- Instrument the run. Log worker identity, test name, input row or instance, start time, end time, and failure cause.
- Increase concurrency gradually. Stop when runtime no longer improves or resource and isolation failures increase.
- Document the effective build path. Record TestNG and Surefire versions, the suite file, and any data-provider pool settings.
- Evaluate the allocator against the same evidence. Run the comparison only after its scheduling unit, worker cap, ordering, and failure semantics are documented.
Bottom line
Configure native TestNG parallelism by selecting methods, tests, classes, or instances on <suite>, then set a measured thread-count. Add the documented data-provider pool attributes when using TestNG 7.9.0 or later, and keep Maven Surefire settings aligned with the plugin version in use. TestNG’s scheduler is defined; the “custom Excel allocator” is not. Until its implementation and rules are available, compare it by work unit, concurrency cap, grouping, ordering, data-provider integration, thread safety, and build operations rather than claiming parity or a performance advantage.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

