Run tests using Surefire.
Mojo Attributes:
testtest| Name | Type | Description |
|---|---|---|
| basedir | File |
The base directory of the project being tested. This can be obtained in your unit test by System.getProperty("basedir"). |
| classesDirectory | File |
The directory containing generated classes of the project being tested. |
| testClassesDirectory | File |
The directory containing generated test classes of the project being tested. |
| testSourceDirectory | File |
The test source directory containing test class sources. |
| Name | Type | Description |
|---|---|---|
| additionalClasspathElements | List |
Additional elements to be appended to the classpath. |
| argLine | String |
Arbitrary JVM options to set on the command line. |
| artifactFactory | ArtifactFactory |
Creates the artifact |
| artifactResolver | ArtifactResolver |
Resolves the artifacts needed. |
| childDelegation | boolean |
When false it makes tests run using the standard classloader delegation instead of the default Maven isolated
classloader. Only used when forking (forkMode is not "none"). Setting it to false helps with some problems caused by conflicts between xml parsers in the classpath and the Java 5 provider parser. Default value is false. |
| debugForkedProcess | String |
Attach a debugger to the forked JVM. If set to "true", the process will suspend and wait for a debugger to attach on port 5005. If set to some other string, that string will be appended to the argLine, allowing you to configure arbitrary debuggability options (without overwriting the other options specified in the argLine). |
| disableXmlReport | boolean |
Flag to disable the generation of report files in xml format. Default value is false. |
| enableAssertions | boolean |
By default, Surefire enables JVM assertions for the execution of your test cases. To disable the assertions, set
this flag to false. Default value is true. |
| environmentVariables | Map |
Additional environments to set on the command line. |
| excludedGroups | String |
(TestNG only) Excluded groups. Any methods/classes/etc with one of the groups specified in this list will specifically not be run. This parameter is overridden if suiteXmlFiles are specified. |
| excludes | List |
List of patterns (separated by commas) used to specify the tests that should be excluded in testing. When not
specified and when the test parameter is not specified, the default excludes will be
**/*$* (which excludes all inner classes). This parameter is ignored if
TestNG suiteXmlFiles are specified. |
| failIfNoTests | Boolean |
Set this to "true" to cause a failure if there are no tests to run. Defaults to false. |
| forkMode | String |
Option to specify the forking mode. Can be "never", "once" or "always". "none" and "pertest" are also accepted
for backwards compatibility. Default value is once. |
| forkedProcessTimeoutInSeconds | int |
Kill the forked test process after a certain number of seconds. If set to 0, wait forever for the process, never timing out. |
| groups | String |
(TestNG only) Groups for this test. Only classes/methods/etc decorated with one of the groups specified here will be included in test run, if specified. This parameter is overridden if suiteXmlFiles are specified. |
| includes | List |
List of patterns (separated by commas) used to specify the tests that should be included in testing. When not
specified and when the test parameter is not specified, the default includes will be
**/Test*.java **/*Test.java **/*TestCase.java. This parameter is ignored if
TestNG suiteXmlFiles are specified. |
| junitArtifactName | String |
Allows you to specify the name of the JUnit artifact. If not set, junit:junit will be used. Default value is junit:junit. |
| jvm | String |
Option to specify the jvm (or path to the java executable) to use with the forking options. For the default, the jvm will be the same as the one used to run Maven. |
| metadataSource | ArtifactMetadataSource |
For retrieval of artifact's metadata. |
| parallel | String |
(TestNG only) When you use the parallel attribute, TestNG will try to run all your test methods in separate threads, except for methods that depend on each other, which will be run in the same thread in order to respect their order of execution. |
| printSummary | boolean |
Option to print summary of test suites or just print the test cases that has errors. Default value is true. |
| properties | Properties |
List of properties for configuring all TestNG related configurations. This is the new preferred method of configuring TestNG. |
| redirectTestOutputToFile | boolean |
When forking, set this to true to redirect the unit test standard output to a file (found in
reportsDirectory/testName-output.txt). Default value is false. |
| remoteRepositories | List |
The plugin remote repositories declared in the pom. |
| reportFormat | String |
Selects the formatting for the test report to be generated. Can be set as brief or plain. Default value is brief. |
| reportsDirectory | File |
Base directory where all reports are written to. |
| skip | boolean |
Set this to 'true' to bypass unit tests entirely. Its use is NOT RECOMMENDED, especially if you enable it using the "maven.test.skip" property, because maven.test.skip disables both running the tests and compiling the tests. Consider using the skipTests parameter instead. |
| skipExec | boolean |
DEPRECATED This old parameter is just like skipTests, but bound to the old property maven.test.skip.exec. Use -DskipTests instead; it's shorter. |
| skipTests | boolean |
Set this to 'true' to skip running tests, but still compile them. Its use is NOT RECOMMENDED, but quite convenient on occasion. |
| suiteXmlFiles | File[] |
(TestNG only) List of TestNG suite xml file locations, seperated by commas. Note that suiteXmlFiles is incompatible with several other parameters on this plugin, like includes/excludes. This parameter is ignored if the "test" parameter is specified (allowing you to run a single test instead of an entire suite). |
| systemProperties | Properties |
List of System properties to pass to the JUnit tests. |
| test | String |
Specify this parameter to run individual tests by file name, overriding the includes/excludes
parameters. Each pattern you specify here will be used to create an
include pattern formatted like **/${test}.java, so you can just type "-Dtest=MyTest"
to run a single test called "foo/MyTest.java". This parameter will override the TestNG suiteXmlFiles
parameter. |
| testFailureIgnore | boolean |
Set this to true to ignore a failure during testing. Its use is NOT RECOMMENDED, but quite convenient on occasion. |
| testNGArtifactName | String |
Allows you to specify the name of the TestNG artifact. If not set, org.testng:testng will be used. Default value is org.testng:testng. |
| threadCount | int |
(TestNG only) The attribute thread-count allows you to specify how many threads should be allocated for this execution. Only makes sense to use in conjunction with parallel. |
| trimStackTrace | boolean |
Whether to trim the stack trace in the reports to just the lines within the test, or show the full trace. Default value is true. |
| useFile | boolean |
Option to generate a file test report or just output the test report to the console. Default value is true. |
| useManifestOnlyJar | boolean |
By default, Surefire forks your tests using a manifest-only jar; set this parameter
to "false" to force it to launch your tests with a plain old Java classpath.
(See http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html
for a more detailed explanation of manifest-only jars and their benefits.)
Default value is "true". Beware, setting this to "false" may cause your tests to
fail on Windows if your classpath is too long. Default value is true. |
| useSystemClassLoader | Boolean |
Option to pass dependencies to the system's classloader instead of using an isolated class loader when forking. Prevents problems with JDKs which implement the service provider lookup mechanism by using the system's classloader. Default value is "true". |
| workingDirectory | File |
Command line working directory. |
java.util.List2.4Nojava.lang.String2.1No${argLine}org.apache.maven.artifact.factory.ArtifactFactoryNoorg.apache.maven.artifact.resolver.ArtifactResolverNojava.io.FileYes${basedir}boolean2.1No${childDelegation}falsejava.io.FileYes${project.build.outputDirectory}java.lang.String2.4No${maven.surefire.debug}boolean2.2No${disableXmlReport}falsefalse.
boolean2.3.1No${enableAssertions}truejava.util.Map2.1.3Nojava.lang.String2.2No${excludedGroups}test parameter is not specified, the default excludes will be
**/*$* (which excludes all inner classes). This parameter is ignored if
TestNG suiteXmlFiles are specified.
java.util.ListNojava.lang.Boolean2.4No${failIfNoTests}java.lang.String2.1No${forkMode}onceint2.4No${surefire.timeout}java.lang.String2.2No${groups}test parameter is not specified, the default includes will be
**/Test*.java **/*Test.java **/*TestCase.java. This parameter is ignored if
TestNG suiteXmlFiles are specified.
java.util.ListNojunit:junit will be used.
java.lang.String2.3.1No${junitArtifactName}junit:junitjava.lang.String2.1No${jvm}org.apache.maven.artifact.metadata.ArtifactMetadataSourceNojava.lang.String2.2No${parallel}booleanNo${surefire.printSummary}truejava.util.Properties2.4Noboolean2.3No${maven.test.redirectTestOutputToFile}falsejava.util.List2.2No${project.pluginArtifactRepositories}java.lang.StringNo${surefire.reportFormat}briefjava.io.FileNo${project.build.directory}/surefire-reportsbooleanNo${maven.test.skip}boolean2.3No${maven.test.skip.exec}boolean2.4No${skipTests}java.io.File[]2.2Nojava.util.PropertiesNoincludes/excludes
parameters. Each pattern you specify here will be used to create an
include pattern formatted like **/${test}.java, so you can just type "-Dtest=MyTest"
to run a single test called "foo/MyTest.java". This parameter will override the TestNG suiteXmlFiles
parameter.
java.lang.StringNo${test}java.io.FileYes${project.build.testOutputDirectory}booleanNo${maven.test.failure.ignore}org.testng:testng will be used.
java.lang.String2.3.1No${testNGArtifactName}org.testng:testngjava.io.File2.2Yes${project.build.testSourceDirectory}int2.2No${threadCount}boolean2.2No${trimStackTrace}truebooleanNo${surefire.useFile}trueboolean2.4.3No${surefire.useManifestOnlyJar}truejava.lang.Boolean2.3No${surefire.useSystemClassLoader}java.io.File2.1.3No${basedir}