Package org.apache.maven.plugin.surefire
Class SurefireMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugin.surefire.AbstractSurefireMojo
-
- org.apache.maven.plugin.surefire.SurefireMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
,org.apache.maven.plugin.surefire.SurefireExecutionParameters
,org.apache.maven.plugin.surefire.SurefireReportParameters
@Mojo(name="test", defaultPhase=TEST, threadSafe=true, requiresDependencyResolution=TEST) public class SurefireMojo extends org.apache.maven.plugin.surefire.AbstractSurefireMojo implements org.apache.maven.plugin.surefire.SurefireReportParameters
Run tests using Surefire.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.maven.plugin.surefire.AbstractSurefireMojo
org.apache.maven.plugin.surefire.AbstractSurefireMojo.DynamicProviderInfo, org.apache.maven.plugin.surefire.AbstractSurefireMojo.JUnit3ProviderInfo, org.apache.maven.plugin.surefire.AbstractSurefireMojo.JUnit4ProviderInfo, org.apache.maven.plugin.surefire.AbstractSurefireMojo.JUnitCoreProviderInfo, org.apache.maven.plugin.surefire.AbstractSurefireMojo.JUnitPlatformProviderInfo, org.apache.maven.plugin.surefire.AbstractSurefireMojo.JUnitPlatformProviderShadefireInfo, org.apache.maven.plugin.surefire.AbstractSurefireMojo.PluginFailureReason, org.apache.maven.plugin.surefire.AbstractSurefireMojo.TestNgProviderInfo
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.File
classesDirectory
The directory containing generated classes of the project being tested.private java.lang.String
debugForkedProcess
Attach a debugger to the forked JVM.private java.lang.String
enableProcessChecker
Since 3.0.0-M4 the process checkers are disabled.private java.lang.String
encoding
The character encoding scheme to be applied while generating test report files (see target/surefire-reports/yourTestName.txt).private java.lang.String[]
excludedEnvironmentVariables
You can selectively exclude individual environment variables by enumerating their keys.private java.lang.String[]
excludeJUnit5Engines
Provide the ID/s of an JUnit engine to be excluded in the test run.private java.util.List<java.lang.String>
excludes
A list of <exclude> elements specifying the tests (by pattern) that should be excluded in testing.private java.io.File
excludesFile
A file containing exclude patterns.private boolean
failIfNoSpecifiedTests
Set this to "true" to cause a failure if none of the tests specified in -Dtest=...private int
failOnFlakeCount
Set this to a value greater than 0 to fail the whole test set if the cumulative number of flakes reaches this threshold.private int
forkedProcessExitTimeoutInSeconds
Forked process is normally terminated without any significant delay after given tests have completed.private int
forkedProcessTimeoutInSeconds
Kill the forked test process after a certain number of seconds.private org.apache.maven.surefire.extensions.ForkNodeFactory
forkNode
This parameter configures the forked node.private java.lang.String[]
includeJUnit5Engines
Provide the ID/s of an JUnit engine to be included in the test run.private java.util.List<java.lang.String>
includes
private java.io.File
includesFile
A file containing include patterns.private double
parallelTestsTimeoutForcedInSeconds
Stop executing queued parallel JUnit tests andinterrupt
currently running tests after a certain number of seconds.private double
parallelTestsTimeoutInSeconds
Stop executing queued parallel JUnit tests after a certain number of seconds.private boolean
printSummary
Option to print summary of test suites or just print the test cases that have errors.private java.lang.String
reportFormat
Selects the formatting for the test report to be generated.private java.io.File
reportsDirectory
Base directory where all reports are written to.private int
rerunFailingTestsCount
(JUnit 4+ providers and JUnit 5+ providers since 3.0.0-M4) The number of times each failing test will be rerun.private java.lang.String
runOrder
Defines the order the tests will be run in.private java.lang.Long
runOrderRandomSeed
Sets the random seed that will be used to order the tests ifsurefire.runOrder
is set torandom
.private java.lang.String
shutdown
After the plugin process is shutdown by sending SIGTERM signal (CTRL+C), SHUTDOWN command is received by every forked JVM.private int
skipAfterFailureCount
Set to error/failure count in order to skip remaining tests.private java.io.File[]
suiteXmlFiles
(TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file locations.private java.io.File
systemPropertiesFile
Properties file being used as system properties passed to the provider.private java.lang.String
test
private boolean
testFailureIgnore
Set this to "true" to ignore a failure during testing.private boolean
useFile
Option to generate a file test report or just output the test report to the console.private boolean
useManifestOnlyJar
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.private boolean
useModulePath
Whentrue
, uses the modulepath when executing with JDK 9+ and module-info.java is present.private boolean
useSystemClassLoader
Option to pass dependencies to the system's classloader instead of using an isolated class loader when forking.
-
Constructor Summary
Constructors Constructor Description SurefireMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
addPluginSpecificChecksumItems(org.apache.maven.plugin.surefire.booterclient.ChecksumCalculator checksum)
java.io.File
getBasedir()
java.lang.String
getDebugForkedProcess()
protected java.lang.String[]
getDefaultIncludes()
protected java.lang.String
getEnableProcessChecker()
java.lang.String
getEncoding()
protected java.lang.String[]
getExcludedEnvironmentVariables()
java.lang.String[]
getExcludeJUnit5Engines()
java.util.List<java.lang.String>
getExcludes()
java.io.File
getExcludesFile()
boolean
getFailIfNoSpecifiedTests()
int
getFailOnFlakeCount()
int
getForkedProcessExitTimeoutInSeconds()
int
getForkedProcessTimeoutInSeconds()
protected org.apache.maven.surefire.extensions.ForkNodeFactory
getForkNode()
java.lang.String[]
getIncludeJUnit5Engines()
java.util.List<java.lang.String>
getIncludes()
java.io.File
getIncludesFile()
java.io.File
getMainBuildPath()
double
getParallelTestsTimeoutForcedInSeconds()
double
getParallelTestsTimeoutInSeconds()
protected java.lang.String
getPluginName()
java.lang.String
getReportFormat()
protected java.lang.String
getReportSchemaLocation()
java.io.File
getReportsDirectory()
protected int
getRerunFailingTestsCount()
java.lang.String
getRunOrder()
java.lang.Long
getRunOrderRandomSeed()
java.lang.String
getShutdown()
int
getSkipAfterFailureCount()
java.io.File[]
getSuiteXmlFiles()
java.io.File
getSystemPropertiesFile()
java.lang.String
getTest()
java.io.File
getTestClassesDirectory()
protected void
handleSummary(org.apache.maven.surefire.api.suite.RunResult summary, java.lang.Exception firstForkException)
protected boolean
hasSuiteXmlFiles()
boolean
isPrintSummary()
boolean
isSkip()
boolean
isSkipExec()
Deprecated.protected boolean
isSkipExecution()
boolean
isSkipTests()
boolean
isTestFailureIgnore()
boolean
isUseFile()
boolean
isUseManifestOnlyJar()
boolean
isUseSystemClassLoader()
void
setBasedir(java.io.File basedir)
void
setDebugForkedProcess(java.lang.String debugForkedProcess)
void
setEncoding(java.lang.String encoding)
(package private) void
setExcludedEnvironmentVariables(java.lang.String[] excludedEnvironmentVariables)
void
setExcludeJUnit5Engines(java.lang.String[] excludeJUnit5Engines)
void
setExcludes(java.util.List<java.lang.String> excludes)
void
setFailIfNoSpecifiedTests(boolean failIfNoSpecifiedTests)
void
setFailOnFlakeCount(int failOnFlakeCount)
void
setForkedProcessExitTimeoutInSeconds(int forkedProcessExitTimeoutInSeconds)
void
setForkedProcessTimeoutInSeconds(int forkedProcessTimeoutInSeconds)
void
setIncludeJUnit5Engines(java.lang.String[] includeJUnit5Engines)
void
setIncludes(java.util.List<java.lang.String> includes)
void
setMainBuildPath(java.io.File mainBuildPath)
void
setParallelTestsTimeoutForcedInSeconds(double parallelTestsTimeoutForcedInSeconds)
void
setParallelTestsTimeoutInSeconds(double parallelTestsTimeoutInSeconds)
void
setPrintSummary(boolean printSummary)
void
setReportFormat(java.lang.String reportFormat)
void
setReportsDirectory(java.io.File reportsDirectory)
void
setRunOrder(java.lang.String runOrder)
void
setRunOrderRandomSeed(java.lang.Long runOrderRandomSeed)
void
setSkip(boolean skip)
void
setSkipExec(boolean skipExec)
Deprecated.void
setSkipTests(boolean skipTests)
void
setSuiteXmlFiles(java.io.File[] suiteXmlFiles)
void
setSystemPropertiesFile(java.io.File systemPropertiesFile)
void
setTest(java.lang.String test)
void
setTestClassesDirectory(java.io.File testClassesDirectory)
void
setTestFailureIgnore(boolean testFailureIgnore)
void
setUseFile(boolean useFile)
void
setUseManifestOnlyJar(boolean useManifestOnlyJar)
protected void
setUseModulePath(boolean useModulePath)
void
setUseSystemClassLoader(boolean useSystemClassLoader)
protected java.util.List<java.io.File>
suiteXmlFiles()
protected boolean
useModulePath()
protected void
warnIfIllegalFailOnFlakeCount()
-
Methods inherited from class org.apache.maven.plugin.surefire.AbstractSurefireMojo
cleanupForkConfiguration, convertWithCoreCount, createCopyAndReplaceForkNumPlaceholder, createProviders, createSurefireBootDirectoryInBuild, createSurefireBootDirectoryInTemp, effectiveIsEnableAssertions, execute, getAdditionalClasspathElements, getArgLine, getClassLoaderConfiguration, getClasspathDependencyExcludes, getClasspathDependencyScopeExclude, getConsoleLogger, getDependenciesToScan, getEffectiveForkCount, getEnvironmentVariables, getExcludedGroups, getFailIfNoTests, getForkCount, getGroups, getJdkToolchain, getJunitArtifactName, getJvm, getLocalRepositoryPath, getMojoArtifact, getObjectFactory, getParallel, getPerCoreThreadCount, getPluginArtifactMap, getPluginDescriptor, getProject, getProjectArtifactMap, getProjectBuildDirectory, getProjectTestArtifacts, getReportNameSuffix, getSession, getSpecificTests, getSurefireTempDir, getSystemProperties, getSystemPropertyVariables, getTempDir, getTestNGArtifactName, getTestSourceDirectory, getThreadCount, getThreadCountClasses, getThreadCountMethods, getThreadCountSuites, getToolchainManager, getUserProperties, getUseUnlimitedThreads, getWorkingDirectory, hasExecutedBefore, isAnyConcurrencySelected, isAnyGroupsSelected, isChildDelegation, isDisableXmlReport, isEnableAssertions, isEnableOutErrElements, isEnablePropertiesElement, isForking, isMavenParallel, isParallelOptimized, isRedirectTestOutputToFile, isReuseForks, isTrimStackTrace, logDebugOrCliShowErrors, logReportsDirectory, resolveDependencies, scanDependencies, setAdditionalClasspathElements, setArgLine, setChildDelegation, setClasspathDependencyExcludes, setClasspathDependencyScopeExclude, setDependenciesToScan, setDisableXmlReport, setEnableAssertions, setEnableOutErrElements, setEnablePropertiesElement, setEnvironmentVariables, setExcludedGroups, setFailIfNoTests, setGroups, setJdkToolchain, setJunitArtifactName, setLogger, setObjectFactory, setParallel, setParallelOptimized, setPerCoreThreadCount, setPluginArtifactMap, setPluginDescriptor, setProject, setProjectArtifactMap, setProjectBuildDirectory, setProperties, setRedirectTestOutputToFile, setReportNameSuffix, setSession, setSurefireDependencyResolver, setSystemProperties, setSystemPropertyVariables, setTempDir, setTestNGArtifactName, setTestSourceDirectory, setThreadCount, setThreadCountClasses, setThreadCountMethods, setThreadCountSuites, setToolchainManager, setTrimStackTrace, setupProperties, setUseUnlimitedThreads, setWorkingDirectory, verifyParameters
-
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
-
-
-
Field Detail
-
classesDirectory
@Parameter(defaultValue="${project.build.outputDirectory}") private java.io.File classesDirectory
The directory containing generated classes of the project being tested. This will be included after the test classes in the test classpath.
-
testFailureIgnore
@Parameter(property="maven.test.failure.ignore", defaultValue="false") private boolean testFailureIgnore
Set this to "true" to ignore a failure during testing. Its use is NOT RECOMMENDED, but quite convenient on occasion.
-
reportsDirectory
@Parameter(defaultValue="${project.build.directory}/surefire-reports") private java.io.File reportsDirectory
Base directory where all reports are written to.
-
test
@Parameter(property="test") private java.lang.String test
-
printSummary
@Parameter(property="surefire.printSummary", defaultValue="true") private boolean printSummary
Option to print summary of test suites or just print the test cases that have errors.
-
reportFormat
@Parameter(property="surefire.reportFormat", defaultValue="brief") private java.lang.String reportFormat
Selects the formatting for the test report to be generated. Can be set as "brief" or "plain". Only applies to the output format of the output files (target/surefire-reports/testName.txt)
-
useFile
@Parameter(property="surefire.useFile", defaultValue="true") private boolean useFile
Option to generate a file test report or just output the test report to the console.
-
failIfNoSpecifiedTests
@Parameter(property="surefire.failIfNoSpecifiedTests", defaultValue="true") private boolean failIfNoSpecifiedTests
Set this to "true" to cause a failure if none of the tests specified in -Dtest=... are run. Defaults to "true".- Since:
- 2.12
-
debugForkedProcess
@Parameter(property="maven.surefire.debug") private java.lang.String debugForkedProcess
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 through theargLine
parameter).- Since:
- 2.4
-
forkedProcessTimeoutInSeconds
@Parameter(property="surefire.timeout") private int forkedProcessTimeoutInSeconds
Kill the forked test process after a certain number of seconds. If set to 0, wait forever for the process, never timing out.- Since:
- 2.4
-
forkedProcessExitTimeoutInSeconds
@Parameter(property="surefire.exitTimeout", defaultValue="30") private int forkedProcessExitTimeoutInSeconds
Forked process is normally terminated without any significant delay after given tests have completed. If the particular tests started non-daemon Thread(s), the process hangs instead of been properly terminated bySystem.exit()
. Use this parameter in order to determine the timeout of terminating the process. see the documentation: http://maven.apache.org/surefire/maven-surefire-plugin/examples/shutdown.html Turns to default fallback value of 30 seconds if negative integer.- Since:
- 2.20
-
parallelTestsTimeoutInSeconds
@Parameter(property="surefire.parallel.timeout") private double parallelTestsTimeoutInSeconds
Stop executing queued parallel JUnit tests after a certain number of seconds.
Example values: "3.5", "4"
If set to 0, wait forever, never timing out. Makes sense with specifiedparallel
different from "none".- Since:
- 2.16
-
parallelTestsTimeoutForcedInSeconds
@Parameter(property="surefire.parallel.forcedTimeout") private double parallelTestsTimeoutForcedInSeconds
Stop executing queued parallel JUnit tests andinterrupt
currently running tests after a certain number of seconds.
Example values: "3.5", "4"
If set to 0, wait forever, never timing out. Makes sense with specifiedparallel
different from "none".- Since:
- 2.16
-
includes
@Parameter(property="surefire.includes") private java.util.List<java.lang.String> includes
-
excludes
@Parameter(property="surefire.excludes") private java.util.List<java.lang.String> excludes
A list of <exclude> elements specifying the tests (by pattern) that should be excluded in testing. When not specified and when thetest
parameter is not specified, the default excludes will be
(which excludes all inner classes).<excludes> <exclude>**/*$*</exclude> </excludes>
This parameter is ignored if the TestNGsuiteXmlFiles
parameter is specified.
Each exclude item may also contain a comma-separated sub-list of items, which will be treated as multiple <exclude> entries.
Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):<exclude>%regex[pkg.*Slow.*.class], Unstable*</exclude>
Notice that these values are relative to the directory containing generated test classes of the project being tested. This directory is declared by the parametertestClassesDirectory
which defaults to the POM property${project.build.testOutputDirectory}
, typicallysrc/test/java
unless overridden.
-
useSystemClassLoader
@Parameter(property="surefire.useSystemClassLoader", defaultValue="true") private boolean useSystemClassLoader
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.- Since:
- 2.3
-
useManifestOnlyJar
@Parameter(property="surefire.useManifestOnlyJar", defaultValue="true") private boolean useManifestOnlyJar
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 the http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html for a more detailed explanation of manifest-only JARs and their benefits.)
Beware, setting this to "false" may cause your tests to fail on Windows if your classpath is too long.- Since:
- 2.4.3
-
encoding
@Parameter(property="surefire.encoding", defaultValue="${project.reporting.outputEncoding}") private java.lang.String encoding
The character encoding scheme to be applied while generating test report files (see target/surefire-reports/yourTestName.txt). The report output files (*-out.txt) are encoded in UTF-8 if not set otherwise.- Since:
- 3.0.0-M1
-
rerunFailingTestsCount
@Parameter(property="surefire.rerunFailingTestsCount", defaultValue="0") private int rerunFailingTestsCount
(JUnit 4+ providers and JUnit 5+ providers since 3.0.0-M4) The number of times each failing test will be rerun. If set larger than 0, rerun failing tests immediately after they fail. If a failing test passes in any of those reruns, it will be marked as pass and reported as a "flake". However, all the failing attempts will be recorded.
-
failOnFlakeCount
@Parameter(property="surefire.failOnFlakeCount", defaultValue="0") private int failOnFlakeCount
Set this to a value greater than 0 to fail the whole test set if the cumulative number of flakes reaches this threshold. Set to 0 to allow an unlimited number of flakes.- Since:
- 3.0.0-M6
-
suiteXmlFiles
@Parameter(property="surefire.suiteXmlFiles") private java.io.File[] suiteXmlFiles
(TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file locations. Note thatsuiteXmlFiles
is incompatible with several other parameters of this plugin, likeincludes
andexcludes
.
This parameter is ignored if thetest
parameter is specified (allowing you to run a single test instead of an entire suite).- Since:
- 2.2
-
runOrder
@Parameter(property="surefire.runOrder", defaultValue="filesystem") private java.lang.String runOrder
Defines the order the tests will be run in. Supported values arealphabetical
,reversealphabetical
,random
,hourly
(alphabetical on even hours, reverse alphabetical on odd hours),failedfirst
,balanced
andfilesystem
.
Odd/Even for hourly is determined at the time the of scanning the classpath, meaning it could change during a multi-module build.
Failed first will run tests that failed on previous run first, as well as new tests for this run.
Balanced is only relevant with parallel=classes, and will try to optimize the run-order of the tests reducing the overall execution time. Initially a statistics file is created and every next test run will reorder classes.
Note that the statistics are stored in a file named .surefire-XXXXXXXXX beside pom.xml and should not be checked into version control. The "XXXXX" is the SHA1 checksum of the entire surefire configuration, so different configurations will have different statistics files, meaning if you change any configuration settings you will re-run once before new statistics data can be established.- Since:
- 2.7
-
runOrderRandomSeed
@Parameter(property="surefire.runOrder.random.seed") private java.lang.Long runOrderRandomSeed
Sets the random seed that will be used to order the tests ifsurefire.runOrder
is set torandom
.
If no seeds are set andsurefire.runOrder
is set torandom
, then the seed used will be outputted (search for "To reproduce ordering use flag -Dsurefire.runOrder.random.seed").
To deterministically reproduce any random test order that was run before, simply set the seed to be the same value.- Since:
- 3.0.0-M6
-
includesFile
@Parameter(property="surefire.includesFile") private java.io.File includesFile
A file containing include patterns. Blank lines, or lines starting with # are ignored. Ifincludes
are also specified, these patterns are appended. Example with path, simple and regex includes:*/test/* **/NotIncludedByDefault.java %regex[.*Test.*|.*Not.*]
Since 3.0.0-M6, method filtering support is provided in the inclusions file as well, example:pkg.SomeTest#testMethod
- Since:
- 2.13
-
excludesFile
@Parameter(property="surefire.excludesFile") private java.io.File excludesFile
A file containing exclude patterns. Blank lines, or lines starting with # are ignored. Ifexcludes
are also specified, these patterns are appended. Example with path, simple and regex excludes:
Since 3.0.0-M6, method filtering support is provided in the exclusions file as well, example:*/test/* **/DontRunTest.* %regex[.*Test.*|.*Not.*]
pkg.SomeTest#testMethod
- Since:
- 2.13
-
skipAfterFailureCount
@Parameter(property="surefire.skipAfterFailureCount", defaultValue="0") private int skipAfterFailureCount
Set to error/failure count in order to skip remaining tests. Due to race conditions in parallel/forked execution this may not be fully guaranteed.
Enable with system property-Dsurefire.skipAfterFailureCount=1
or any number greater than zero. Defaults to "0".
See the prerequisites and limitations in documentation:
http://maven.apache.org/plugins/maven-surefire-plugin/examples/skip-after-failure.html- Since:
- 2.19
-
shutdown
@Parameter(property="surefire.shutdown", defaultValue="exit") private java.lang.String shutdown
After the plugin process is shutdown by sending SIGTERM signal (CTRL+C), SHUTDOWN command is received by every forked JVM.
The value is set to (shutdown=exit
) by default (changed in version 3.0.0-M4).
The parameter can be configured with other two valuestestset
andkill
.
With(shutdown=testset
) the test set may still continue to run in forked JVM.
Usingexit
forked JVM executesSystem.exit(1)
after the plugin process has received SIGTERM signal.
Usingkill
the JVM executesRuntime.halt(1)
and kills itself.- Since:
- 2.19
-
useModulePath
@Parameter(property="surefire.useModulePath", defaultValue="true") private boolean useModulePath
Whentrue
, uses the modulepath when executing with JDK 9+ and module-info.java is present. Whenfalse
, always uses the classpath.
Defaults totrue
.- Since:
- 3.0.0-M2
-
forkNode
@Parameter(property="surefire.forkNode") private org.apache.maven.surefire.extensions.ForkNodeFactory forkNode
This parameter configures the forked node. Currently, you can select the communication protocol, i.e. process pipes or TCP/IP sockets. The plugin uses process pipes by default which will be turned to TCP/IP in the version 3.0.0. Alternatively, you can implement your own factory and SPI.
See the documentation for more details:
https://maven.apache.org/plugins/maven-surefire-plugin/examples/process-communication.html- Since:
- 3.0.0-M5
-
excludedEnvironmentVariables
@Parameter(property="surefire.excludedEnvironmentVariables") private java.lang.String[] excludedEnvironmentVariables
You can selectively exclude individual environment variables by enumerating their keys.
The environment is a system-dependent mapping from keys to values which is inherited from the Maven process to the forked Surefire processes. The keys must literally (case sensitive) match in order to exclude their environment variable.
Example to exclude three environment variables:
mvn test -Dsurefire.excludedEnvironmentVariables=ACME1,ACME2,ACME3- Since:
- 3.0.0-M4
-
enableProcessChecker
@Parameter(property="surefire.enableProcessChecker") private java.lang.String enableProcessChecker
Since 3.0.0-M4 the process checkers are disabled. You can enable them namely by settingping
andnative
orall
in this parameter.
The checker is useful in situations when you kill the build on a CI system and you want the Surefire forked JVM to kill the tests asap and free all handlers on the file system been previously used by the JVM and by the tests.
Theping
should be safely used together with ZGC or Shenandoah Garbage Collector. Due to theping
relies on timing of the PING (triggered every 30 seconds), slow GCs may pause the timers and pretend that the parent process of the forked JVM does not exist.
Thenative
is very fast checker. It is useful mechanism on Unix based systems, Linux distributions and Alpine/BusyBox Linux. See the JIRA SUREFIRE-1631 for Windows issues.
Another useful configuration parameter isforkedProcessTimeoutInSeconds
.
See the Frequently Asked Questions page with more details:
http://maven.apache.org/surefire/maven-surefire-plugin/faq.html#kill-jvm
http://maven.apache.org/surefire/maven-failsafe-plugin/faq.html#kill-jvm
Example of use:
mvn test -Dsurefire.enableProcessChecker=all- Since:
- 3.0.0-M4
-
systemPropertiesFile
@Parameter(property="surefire.systemPropertiesFile") private java.io.File systemPropertiesFile
Properties file being used as system properties passed to the provider.- See Also:
for how the effective provider properties are calculated
-
includeJUnit5Engines
@Parameter(property="surefire.includeJUnit5Engines") private java.lang.String[] includeJUnit5Engines
Provide the ID/s of an JUnit engine to be included in the test run.- Since:
- 3.0.0-M6
-
excludeJUnit5Engines
@Parameter(property="surefire.excludeJUnit5Engines") private java.lang.String[] excludeJUnit5Engines
Provide the ID/s of an JUnit engine to be excluded in the test run.- Since:
- 3.0.0-M6
-
-
Method Detail
-
getRerunFailingTestsCount
protected int getRerunFailingTestsCount()
- Specified by:
getRerunFailingTestsCount
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getFailOnFlakeCount
public int getFailOnFlakeCount()
- Specified by:
getFailOnFlakeCount
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
setFailOnFlakeCount
public void setFailOnFlakeCount(int failOnFlakeCount)
- Specified by:
setFailOnFlakeCount
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
handleSummary
protected void handleSummary(org.apache.maven.surefire.api.suite.RunResult summary, java.lang.Exception firstForkException) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Specified by:
handleSummary
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
isSkipExecution
protected boolean isSkipExecution()
- Specified by:
isSkipExecution
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getPluginName
protected java.lang.String getPluginName()
- Specified by:
getPluginName
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getDefaultIncludes
protected java.lang.String[] getDefaultIncludes()
- Specified by:
getDefaultIncludes
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getReportSchemaLocation
protected java.lang.String getReportSchemaLocation()
- Specified by:
getReportSchemaLocation
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getSystemPropertiesFile
public java.io.File getSystemPropertiesFile()
- Specified by:
getSystemPropertiesFile
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
setSystemPropertiesFile
public void setSystemPropertiesFile(java.io.File systemPropertiesFile)
- Specified by:
setSystemPropertiesFile
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
isSkipTests
public boolean isSkipTests()
- Specified by:
isSkipTests
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
isSkipTests
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
setSkipTests
public void setSkipTests(boolean skipTests)
- Specified by:
setSkipTests
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
setSkipTests
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
isSkipExec
@Deprecated public boolean isSkipExec()
Deprecated.- Specified by:
isSkipExec
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
isSkipExec
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
setSkipExec
@Deprecated public void setSkipExec(boolean skipExec)
Deprecated.- Specified by:
setSkipExec
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
setSkipExec
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
isSkip
public boolean isSkip()
- Specified by:
isSkip
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
isSkip
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
setSkip
public void setSkip(boolean skip)
- Specified by:
setSkip
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
setSkip
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
isTestFailureIgnore
public boolean isTestFailureIgnore()
- Specified by:
isTestFailureIgnore
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
setTestFailureIgnore
public void setTestFailureIgnore(boolean testFailureIgnore)
- Specified by:
setTestFailureIgnore
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
getBasedir
public java.io.File getBasedir()
- Specified by:
getBasedir
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
getBasedir
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
setBasedir
public void setBasedir(java.io.File basedir)
- Specified by:
setBasedir
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
setBasedir
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
getTestClassesDirectory
public java.io.File getTestClassesDirectory()
- Specified by:
getTestClassesDirectory
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
getTestClassesDirectory
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
setTestClassesDirectory
public void setTestClassesDirectory(java.io.File testClassesDirectory)
- Specified by:
setTestClassesDirectory
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
setTestClassesDirectory
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
getMainBuildPath
public java.io.File getMainBuildPath()
- Specified by:
getMainBuildPath
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setMainBuildPath
public void setMainBuildPath(java.io.File mainBuildPath)
- Specified by:
setMainBuildPath
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
getReportsDirectory
public java.io.File getReportsDirectory()
- Specified by:
getReportsDirectory
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
getReportsDirectory
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
setReportsDirectory
public void setReportsDirectory(java.io.File reportsDirectory)
- Specified by:
setReportsDirectory
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
setReportsDirectory
in interfaceorg.apache.maven.plugin.surefire.SurefireReportParameters
-
getTest
public java.lang.String getTest()
- Specified by:
getTest
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
isUseSystemClassLoader
public boolean isUseSystemClassLoader()
- Specified by:
isUseSystemClassLoader
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setUseSystemClassLoader
public void setUseSystemClassLoader(boolean useSystemClassLoader)
- Specified by:
setUseSystemClassLoader
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
isUseManifestOnlyJar
public boolean isUseManifestOnlyJar()
- Specified by:
isUseManifestOnlyJar
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setUseManifestOnlyJar
public void setUseManifestOnlyJar(boolean useManifestOnlyJar)
- Specified by:
setUseManifestOnlyJar
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
getEncoding
public java.lang.String getEncoding()
- Specified by:
getEncoding
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setEncoding
public void setEncoding(java.lang.String encoding)
- Specified by:
setEncoding
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
getFailIfNoSpecifiedTests
public boolean getFailIfNoSpecifiedTests()
- Specified by:
getFailIfNoSpecifiedTests
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setFailIfNoSpecifiedTests
public void setFailIfNoSpecifiedTests(boolean failIfNoSpecifiedTests)
- Specified by:
setFailIfNoSpecifiedTests
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
getSkipAfterFailureCount
public int getSkipAfterFailureCount()
- Specified by:
getSkipAfterFailureCount
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
getShutdown
public java.lang.String getShutdown()
- Specified by:
getShutdown
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
isPrintSummary
public boolean isPrintSummary()
- Specified by:
isPrintSummary
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setPrintSummary
public void setPrintSummary(boolean printSummary)
- Specified by:
setPrintSummary
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
getReportFormat
public java.lang.String getReportFormat()
- Specified by:
getReportFormat
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setReportFormat
public void setReportFormat(java.lang.String reportFormat)
- Specified by:
setReportFormat
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
isUseFile
public boolean isUseFile()
- Specified by:
isUseFile
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setUseFile
public void setUseFile(boolean useFile)
- Specified by:
setUseFile
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
getDebugForkedProcess
public java.lang.String getDebugForkedProcess()
- Specified by:
getDebugForkedProcess
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setDebugForkedProcess
public void setDebugForkedProcess(java.lang.String debugForkedProcess)
- Specified by:
setDebugForkedProcess
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
getForkedProcessTimeoutInSeconds
public int getForkedProcessTimeoutInSeconds()
- Specified by:
getForkedProcessTimeoutInSeconds
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setForkedProcessTimeoutInSeconds
public void setForkedProcessTimeoutInSeconds(int forkedProcessTimeoutInSeconds)
- Specified by:
setForkedProcessTimeoutInSeconds
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
getForkedProcessExitTimeoutInSeconds
public int getForkedProcessExitTimeoutInSeconds()
- Specified by:
getForkedProcessExitTimeoutInSeconds
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setForkedProcessExitTimeoutInSeconds
public void setForkedProcessExitTimeoutInSeconds(int forkedProcessExitTimeoutInSeconds)
- Specified by:
setForkedProcessExitTimeoutInSeconds
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
getParallelTestsTimeoutInSeconds
public double getParallelTestsTimeoutInSeconds()
- Specified by:
getParallelTestsTimeoutInSeconds
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setParallelTestsTimeoutInSeconds
public void setParallelTestsTimeoutInSeconds(double parallelTestsTimeoutInSeconds)
- Specified by:
setParallelTestsTimeoutInSeconds
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
getParallelTestsTimeoutForcedInSeconds
public double getParallelTestsTimeoutForcedInSeconds()
- Specified by:
getParallelTestsTimeoutForcedInSeconds
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setParallelTestsTimeoutForcedInSeconds
public void setParallelTestsTimeoutForcedInSeconds(double parallelTestsTimeoutForcedInSeconds)
- Specified by:
setParallelTestsTimeoutForcedInSeconds
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setTest
public void setTest(java.lang.String test)
- Specified by:
setTest
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
getIncludes
public java.util.List<java.lang.String> getIncludes()
- Specified by:
getIncludes
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
getIncludes
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
setIncludes
public void setIncludes(java.util.List<java.lang.String> includes)
- Specified by:
setIncludes
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
setIncludes
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getExcludes
public java.util.List<java.lang.String> getExcludes()
- Specified by:
getExcludes
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setExcludes
public void setExcludes(java.util.List<java.lang.String> excludes)
- Specified by:
setExcludes
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
getSuiteXmlFiles
public java.io.File[] getSuiteXmlFiles()
- Specified by:
getSuiteXmlFiles
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
setSuiteXmlFiles
public void setSuiteXmlFiles(java.io.File[] suiteXmlFiles)
- Specified by:
setSuiteXmlFiles
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getRunOrder
public java.lang.String getRunOrder()
- Specified by:
getRunOrder
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
setRunOrder
public void setRunOrder(java.lang.String runOrder)
- Specified by:
setRunOrder
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getRunOrderRandomSeed
public java.lang.Long getRunOrderRandomSeed()
- Specified by:
getRunOrderRandomSeed
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
setRunOrderRandomSeed
public void setRunOrderRandomSeed(java.lang.Long runOrderRandomSeed)
- Specified by:
setRunOrderRandomSeed
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getIncludesFile
public java.io.File getIncludesFile()
- Specified by:
getIncludesFile
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getExcludesFile
public java.io.File getExcludesFile()
- Specified by:
getExcludesFile
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
useModulePath
protected boolean useModulePath()
- Specified by:
useModulePath
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
setUseModulePath
protected void setUseModulePath(boolean useModulePath)
- Specified by:
setUseModulePath
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
suiteXmlFiles
protected final java.util.List<java.io.File> suiteXmlFiles()
- Specified by:
suiteXmlFiles
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
hasSuiteXmlFiles
protected final boolean hasSuiteXmlFiles()
- Specified by:
hasSuiteXmlFiles
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getExcludedEnvironmentVariables
protected final java.lang.String[] getExcludedEnvironmentVariables()
- Specified by:
getExcludedEnvironmentVariables
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
setExcludedEnvironmentVariables
void setExcludedEnvironmentVariables(java.lang.String[] excludedEnvironmentVariables)
-
getEnableProcessChecker
protected final java.lang.String getEnableProcessChecker()
- Specified by:
getEnableProcessChecker
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getForkNode
protected final org.apache.maven.surefire.extensions.ForkNodeFactory getForkNode()
- Specified by:
getForkNode
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
warnIfIllegalFailOnFlakeCount
protected void warnIfIllegalFailOnFlakeCount() throws org.apache.maven.plugin.MojoFailureException
- Overrides:
warnIfIllegalFailOnFlakeCount
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
- Throws:
org.apache.maven.plugin.MojoFailureException
-
addPluginSpecificChecksumItems
protected void addPluginSpecificChecksumItems(org.apache.maven.plugin.surefire.booterclient.ChecksumCalculator checksum)
- Overrides:
addPluginSpecificChecksumItems
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getIncludeJUnit5Engines
public java.lang.String[] getIncludeJUnit5Engines()
- Specified by:
getIncludeJUnit5Engines
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setIncludeJUnit5Engines
public void setIncludeJUnit5Engines(java.lang.String[] includeJUnit5Engines)
- Specified by:
setIncludeJUnit5Engines
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
getExcludeJUnit5Engines
public java.lang.String[] getExcludeJUnit5Engines()
- Specified by:
getExcludeJUnit5Engines
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
setExcludeJUnit5Engines
public void setExcludeJUnit5Engines(java.lang.String[] excludeJUnit5Engines)
- Specified by:
setExcludeJUnit5Engines
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
-
-