A Maven plugin to execute TestNG test suites with full support for all TestNG and ReportNG configuration attributes.
Check Maven Repository releases here
The testng-starter-maven-plugin bridges Maven's build lifecycle and the TestNG test framework by providing a single test goal that:
- Runs one or more TestNG suite XML files (configured or discovered automatically from a directory)
- Registers and configures ReportNG for rich HTML test reports
- Supports test retries, global timeouts, and fail-fast mode
- Allows parallel test execution (methods, classes, instances, tests)
- Accepts custom TestNG listeners and arbitrary system properties
- Optionally re-runs
testng-failed.xmlfor automatic retry of failed tests - Executes tests in an isolated ClassLoader built from the project's resolved dependency graph, so plugin internals never pollute the test classpath
Relationship to ReportNG: This plugin pairs with ReportNG (com.github.sdrss:reportng) to produce detailed HTML test reports. ReportNG is bundled as a plugin dependency — no extra configuration is required in the test project.
- Java 11 or higher
- Maven 3.6+
- TestNG suite XML file(s) (e.g.
src/test/resources/Regression.xml)
<build>
<plugins>
<plugin>
<groupId>com.github.sdrss</groupId>
<artifactId>testng-starter-maven-plugin</artifactId>
<version>2.1.0</version>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
<configuration>
<suiteXmlFiles>src/test/resources/Regression.xml</suiteXmlFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>mvn testng-starter:testThe plugin binds to the test phase by default, so it also runs as part of mvn test or mvn verify.
There are two ways to specify which TestNG suite files to run:
Option A – Explicit paths (full or relative to project root):
mvn testng-starter:test -DsuiteXmlFiles=src/test/resources/Smoke.xml,src/test/resources/Regression.xmlOption B – Directory scan + file name(s):
Set suitesSearchDirectory to a base directory and provide only the file name(s) in suiteXmlFiles. The plugin will recursively search the directory for matching files.
mvn testng-starter:test -DsuitesSearchDirectory=src/test/resources/ -DsuiteXmlFiles=Smoke.xml,Regression.xmlPost-build suites: Use suiteXmlFilesPostBuild to run additional suite(s) after the main suites complete — useful for teardown or code coverage collection.
# Minimal — run a single suite
mvn testng-starter:test -DsuiteXmlFiles=src/test/resources/MySuite.xml
# Parallel execution with retry
mvn testng-starter:test \
-DsuiteXmlFiles=src/test/resources/MySuite.xml \
-Dparallel=METHODS \
-DthreadPoolSize=4 \
-DmaxTestRetryFailures=2 \
-DexecuteTestngFailedxml=true
# Pass system properties and run only specific groups
mvn testng-starter:test \
-DsuiteXmlFiles=src/test/resources/MySuite.xml \
-DsystemProperties=env:staging,timeout:30 \
-Dgroups=smoke
# Fail fast with custom listeners and ReportNG output
mvn testng-starter:test \
-DsuiteXmlFiles=src/test/resources/MySuite1.xml,src/test/resources/MySuite2.xml \
-DfailFast=true \
-DreportNGOutputDirectory=html \
-Dlisteners=com.mypackage.TestListener,com.mypackage.SuiteListener
# Search directory for suites, known defects mode on
mvn testng-starter:test \
-DsuitesSearchDirectory=src/test/resources/ \
-DsuiteXmlFiles=MySuite.xml \
-DhandleKnownDefectsAsFailures=false \
-DmaxTestRetryFailures=2 \
-DexecuteTestngFailedxml=trueAll parameters can be set via <configuration> in pom.xml or as -D command-line properties.
| Parameter | Default | Description |
|---|---|---|
suiteXmlFiles |
(required) | Comma-separated list of TestNG suite XML files to run. Provide full paths or file names when used with suitesSearchDirectory. |
suitesSearchDirectory |
Base directory to recursively search for the suite files listed in suiteXmlFiles. |
|
suiteXmlFilesPostBuild |
Comma-separated suite files to execute after suiteXmlFiles complete. Useful for teardown or coverage tasks. |
|
skipTests |
false |
Skip test execution entirely. |
| Parameter | Default | Description |
|---|---|---|
configFailurePolicy |
SKIP |
How to handle a configuration method (@BeforeMethod etc.) that has failed once. Values: SKIP, CONTINUE. See TestNG docs. |
preserveOrder |
true |
Run tests in the order they are declared in the suite XML. See TestNG docs. |
parallel |
NONE |
Enable parallel execution. Values: NONE, METHODS, CLASSES, INSTANCES, TESTS. See TestNG docs. |
threadPoolSize |
Number of threads to use when parallel is set. See TestNG docs. |
|
suiteThreadPoolSize |
Thread pool size for running multiple suites in parallel. See TestNG docs. | |
dataProviderThreadCount |
Number of threads to use for data providers. See TestNG docs. | |
randomizeSuites |
false |
Randomize the order in which suites are executed. See TestNG docs. |
isJUnit |
false |
Run in JUnit compatibility mode. See TestNG docs. |
groups |
Comma-separated list of groups to include in the run. See TestNG docs. | |
excludedGroups |
Comma-separated list of groups to exclude from the run. See TestNG docs. | |
listeners |
Comma-separated list of fully qualified custom listener class names to register with TestNG (e.g. com.mypackage.MyListener). See TestNG docs. |
|
outputDirectory |
test-output |
Directory where TestNG writes its XML results and default reports. |
toggleFailureIfAllTestsWereSkipped |
When true, fail the build if all tests were skipped (e.g. due to a data provider failure). See TestNG docs. |
|
systemProperties |
Comma-separated key:value pairs set as Java system properties before test execution. Example: env:staging,baseUrl:https://myapp. |
| Parameter | Default | Description |
|---|---|---|
maxTestRetryFailures |
0 |
Maximum number of times a failed test is retried. Set to 0 to disable retries. Requires the ReportNG retry listener (enabled automatically). See ReportNG. |
executeTestngFailedxml |
false |
After the main run, generate and execute testng-failed.xml to re-run only failed tests. Useful in conjunction with maxTestRetryFailures. See TestNG docs. |
globalTestTimeOut |
0 |
Maximum duration (milliseconds) for each test method. Set to 0 to disable the timeout listener. See ReportNG. |
failFast |
false |
Abort the entire test run on the first test failure. Remaining tests are marked as skipped. Requires ReportNG listener (registered automatically). See ReportNG. |
failOnErrors |
false |
Exit with code -1 (build failure) when any test failures are detected, even if Maven would otherwise consider the build successful. See ReportNG. |
cleanupDaemonThreads |
true |
When true, any daemon threads still running after the test execution completes are interrupted and the thread group is destroyed. Set to false if you need background threads (e.g. async report writers or thread pools started by listeners) to finish naturally before the build continues — prevents truncated or incomplete report output. |
| Parameter | Default | Description |
|---|---|---|
generateReportNGhtmlReport |
true |
Generate the ReportNG HTML report. See ReportNG. |
reportNGOutputDirectory |
html |
Sub-directory (under outputDirectory) where the ReportNG HTML report is written. |
reportNGhtmlReportTitle |
Custom title displayed at the top of the ReportNG HTML report. See ReportNG. | |
showPassedConfigurations |
true |
Include passed @Before* / @After* configuration methods in the HTML report. See ReportNG. |
logOutputReport |
false |
Append captured log output to the HTML report. See ReportNG. |
handleKnownDefectsAsFailures |
false |
When true, tests annotated with @KnownDefect are treated as failures rather than a distinct status. See ReportNG. |
escapeOutput |
false |
When true, HTML special characters (<, >, &, etc.) in test output are escaped before being written into the ReportNG HTML report. Set to false to render raw HTML in test output — useful when tests intentionally produce HTML snippets that should appear formatted in the report. See ReportNG. |
| Parameter | Default | Description |
|---|---|---|
generateXMLReport |
true |
Generate the default TestNG XML result report. See TestNG docs. |
generateHtmlReport |
false |
Generate the default TestNG HTML report (separate from ReportNG). See TestNG docs. |
generateJunitReport |
false |
Generate a JUnit-compatible XML report (useful for CI integrations). See TestNG docs. |
- Classpath construction — The plugin collects all project artifacts (test scope included) and builds a
URLClassLoaderfrom them. This ensures that test code and its dependencies are available at runtime without contaminating the plugin's own classloader. - Isolated thread execution —
TestNGStarterMainClassruns inside a customIsolatedThreadGroup. Any uncaught exceptions bubble back to Maven as build failures. Unresponsive threads are terminated after a 15-second grace period. - TestNG configuration — All plugin parameters are translated into
TestNGAPI calls and ReportNG system properties beforeTestNG.run()is invoked. - Listener registration — Depending on configuration, the following listeners are registered automatically:
HTMLReporter(ReportNG) — whengenerateReportNGhtmlReport=trueIAnnotationTransformerListener— whenglobalTestTimeOut > 0ormaxTestRetryFailures > 0FailFastListener— whenfailFast=trueXMLReporter,JUnitXMLReporter— controlled bygenerateXMLReport/generateJunitReport
- Retry run — If
executeTestngFailedxml=trueand failures were recorded, the plugin runstestng-failed.xmlautomatically after the main run.