@Mojo(name="test",
defaultPhase=TEST,
threadSafe=true,
requiresDependencyResolution=TEST)
public class SurefirePlugin
extends AbstractSurefireMojo
implements SurefireReportParameters
AbstractSurefireMojo.DynamicProviderInfo, AbstractSurefireMojo.JUnit3ProviderInfo, AbstractSurefireMojo.JUnit4ProviderInfo, AbstractSurefireMojo.JUnitCoreProviderInfo, AbstractSurefireMojo.ProviderList, AbstractSurefireMojo.TestNgProviderInfo| Modifier and Type | Field and 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.io.File |
excludesFile
A file containing exclude patterns.
|
private java.lang.Boolean |
failIfNoSpecifiedTests
Set this to "true" to cause a failure if the none of the tests specified in -Dtest=...
|
private int |
forkedProcessTimeoutInSeconds
Kill the forked test process after a certain number of seconds.
|
private java.util.List<java.lang.String> |
includes
A list of <include> elements specifying the tests (by pattern) that should be included in testing.
|
private java.io.File |
includesFile
A file containing include patterns.
|
private double |
parallelTestsTimeoutForcedInSeconds
Stop executing queued parallel JUnit tests
and interrupt 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)
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.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.lang.String |
test
Specify this parameter to run individual tests by file name, overriding the
includes/excludes
parameters. |
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 |
useSystemClassLoader
Option to pass dependencies to the system's classloader instead of using an isolated class loader when forking.
|
basedir, FORK_NUMBER_PLACEHOLDER, skip, skipExec, skipTests, testClassesDirectory, THREAD_NUMBER_PLACEHOLDER| Constructor and Description |
|---|
SurefirePlugin() |
| Modifier and Type | Method and Description |
|---|---|
private void |
assertNoException(java.lang.Exception firstForkException) |
java.io.File |
getBasedir() |
java.io.File |
getClassesDirectory() |
java.lang.String |
getDebugForkedProcess() |
protected java.lang.String[] |
getDefaultIncludes() |
java.io.File |
getExcludesFile() |
java.lang.Boolean |
getFailIfNoSpecifiedTests() |
int |
getForkedProcessTimeoutInSeconds() |
java.util.List<java.lang.String> |
getIncludes() |
java.io.File |
getIncludesFile() |
double |
getParallelTestsTimeoutForcedInSeconds() |
double |
getParallelTestsTimeoutInSeconds() |
protected java.lang.String |
getPluginName() |
java.lang.String |
getReportFormat() |
java.io.File |
getReportsDirectory() |
protected int |
getRerunFailingTestsCount() |
java.lang.String |
getRunOrder() |
java.lang.String |
getShutdown() |
int |
getSkipAfterFailureCount() |
java.io.File[] |
getSuiteXmlFiles() |
java.lang.String |
getTest() |
java.io.File |
getTestClassesDirectory() |
protected void |
handleSummary(RunResult summary,
java.lang.Exception firstForkException) |
protected boolean |
hasSuiteXmlFiles() |
boolean |
isPrintSummary() |
boolean |
isSkip() |
boolean |
isSkipExec() |
protected boolean |
isSkipExecution() |
boolean |
isSkipTests() |
boolean |
isTestFailureIgnore() |
boolean |
isUseFile() |
boolean |
isUseManifestOnlyJar() |
boolean |
isUseSystemClassLoader() |
void |
setBasedir(java.io.File basedir) |
void |
setClassesDirectory(java.io.File classesDirectory) |
void |
setDebugForkedProcess(java.lang.String debugForkedProcess) |
void |
setFailIfNoSpecifiedTests(boolean failIfNoSpecifiedTests) |
void |
setForkedProcessTimeoutInSeconds(int forkedProcessTimeoutInSeconds) |
void |
setIncludes(java.util.List<java.lang.String> includes) |
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 |
setSkip(boolean skip) |
void |
setSkipExec(boolean skipExec) |
void |
setSkipTests(boolean skipTests) |
void |
setSuiteXmlFiles(java.io.File[] suiteXmlFiles) |
void |
setTest(java.lang.String test) |
void |
setTestClassesDirectory(java.io.File testClassesDirectory) |
void |
setTestFailureIgnore(boolean testFailureIgnore) |
void |
setUseFile(boolean useFile) |
void |
setUseManifestOnlyJar(boolean useManifestOnlyJar) |
void |
setUseSystemClassLoader(boolean useSystemClassLoader) |
protected java.util.List<java.io.File> |
suiteXmlFiles()
Calls
AbstractSurefireMojo.getSuiteXmlFiles() as list. |
addPluginSpecificChecksumItems, cleanupForkConfiguration, convertWithCoreCount, createCopyAndReplaceForkNumPlaceholder, createProviders, createStartupConfiguration, effectiveIsEnableAssertions, execute, getAdditionalClasspathElements, getArgLine, getArtifactFactory, getArtifactResolver, getClassLoaderConfiguration, getClasspathDependencyExcludes, getClasspathDependencyScopeExclude, getDependenciesToScan, getEffectiveForkCount, getEffectiveForkMode, getEnvironmentVariables, getExcludedGroups, getExcludes, getFailIfNoTests, getForkConfiguration, getForkCount, getForkMode, getGroups, getJunitArtifactName, getJvm, getLocalRepository, getMetadataSource, getObjectFactory, getParallel, getPerCoreThreadCount, getPluginArtifactMap, getPluginDescriptor, getProject, getProjectArtifactMap, getRemoteRepositories, getReportNameSuffix, getSession, getSpecificTests, getStatisticsFileName, getSystemProperties, getSystemPropertiesFile, getSystemPropertyVariables, getTestNGArtifactName, getTestSourceDirectory, getThreadCount, getThreadCountClasses, getThreadCountMethods, getThreadCountSuites, getToolchain, getToolchainManager, getUseUnlimitedThreads, getWorkingDirectory, hasExecutedBefore, isAnyConcurrencySelected, isAnyGroupsSelected, isChildDelegation, isDisableXmlReport, isEnableAssertions, isForking, isForkModeNever, isMavenParallel, isParallelOptimized, isRedirectTestOutputToFile, isReuseForks, isTrimStackTrace, logDebugOrCliShowErrors, logReportsDirectory, setAdditionalClasspathElements, setArgLine, setArtifactFactory, setArtifactResolver, setChildDelegation, setClasspathDependencyExcludes, setClasspathDependencyScopeExclude, setDependenciesToScan, setDisableXmlReport, setEnableAssertions, setEnvironmentVariables, setExcludedGroups, setExcludes, setFailIfNoTests, setForkMode, setGroups, setJunitArtifactName, setLocalRepository, setMetadataSource, setObjectFactory, setParallel, setParallelOptimized, setPerCoreThreadCount, setPluginArtifactMap, setProject, setProjectArtifactMap, setProperties, setRedirectTestOutputToFile, setRemoteRepositories, setReportNameSuffix, setSession, setSystemProperties, setSystemPropertiesFile, setSystemPropertyVariables, setTestNGArtifactName, setTestSourceDirectory, setThreadCount, setThreadCountClasses, setThreadCountMethods, setThreadCountSuites, setToolchainManager, setTrimStackTrace, setUseUnlimitedThreads, setWorkingDirectory, showToLog, verifyParametersgetLog, getPluginContext, setLog, setPluginContextclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetFailIfNoTests, setFailIfNoTests@Parameter(defaultValue="${project.build.outputDirectory}")
private java.io.File classesDirectory
@Parameter(property="maven.test.failure.ignore",
defaultValue="false")
private boolean testFailureIgnore
@Parameter(defaultValue="${project.build.directory}/surefire-reports")
private java.io.File reportsDirectory
@Parameter(property="test") private java.lang.String test
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". The test patterns prefixed with a ! will be excluded.includes/excludes parameters, and the TestNG suiteXmlFiles
parameter.
Since 2.7.3, you can execute a limited number of methods in the test by adding #myMethod or #my*ethod. For
example, "-Dtest=MyTest#myMethod". This is supported for junit 4.x and testNg.@Parameter(property="surefire.printSummary",
defaultValue="true")
private boolean printSummary
@Parameter(property="surefire.reportFormat",
defaultValue="brief")
private java.lang.String reportFormat
@Parameter(property="surefire.useFile",
defaultValue="true")
private boolean useFile
@Parameter(property="surefire.failIfNoSpecifiedTests") private java.lang.Boolean failIfNoSpecifiedTests
@Parameter(property="maven.surefire.debug") private java.lang.String debugForkedProcess
argLine
parameter).@Parameter(property="surefire.timeout") private int forkedProcessTimeoutInSeconds
@Parameter(property="surefire.parallel.timeout") private double parallelTestsTimeoutInSeconds
parallel different from "none".@Parameter(property="surefire.parallel.forcedTimeout") private double parallelTestsTimeoutForcedInSeconds
parallel different from "none".@Parameter private java.util.List<java.lang.String> includes
test parameter is not specified, the default includes will be
<includes>
<include>**/Test*.java</include>
<include>**/*Test.java</include>
<include>**/*TestCase.java</include>
</includes>
Each include item may also contain a comma-separated sublist of items, which will be treated as multiple
<include> entries.suiteXmlFiles parameter is specified.testClassesDirectory which defaults
to the POM property ${project.build.testOutputDirectory}, typically src/test/java
unless overridden.@Parameter(property="surefire.useSystemClassLoader",
defaultValue="true")
private boolean useSystemClassLoader
@Parameter(property="surefire.useManifestOnlyJar",
defaultValue="true")
private boolean useManifestOnlyJar
@Parameter(property="surefire.rerunFailingTestsCount",
defaultValue="0")
private int rerunFailingTestsCount
@Parameter(property="surefire.suiteXmlFiles") private java.io.File[] suiteXmlFiles
suiteXmlFiles is incompatible with several other parameters of this plugin, like
includes/excludes.test parameter is specified (allowing you to run a single test
instead of an entire suite).@Parameter(property="surefire.runOrder",
defaultValue="filesystem")
private java.lang.String runOrder
@Parameter(property="surefire.includesFile") private java.io.File includesFile
includes are
also specified, these patterns are appended. Example with path, simple and regex includes:@Parameter(property="surefire.excludesFile") private java.io.File excludesFile
excludes are
also specified, these patterns are appended. Example with path, simple and regex excludes:@Parameter(property="surefire.skipAfterFailureCount",
defaultValue="0")
private int skipAfterFailureCount
@Parameter(property="surefire.shutdown",
defaultValue="testset")
private java.lang.String shutdown
protected int getRerunFailingTestsCount()
getRerunFailingTestsCount in class AbstractSurefireMojoprotected void handleSummary(RunResult summary, java.lang.Exception firstForkException) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
handleSummary in class AbstractSurefireMojoorg.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureExceptionprivate void assertNoException(java.lang.Exception firstForkException)
throws org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoFailureExceptionprotected boolean isSkipExecution()
isSkipExecution in class AbstractSurefireMojoprotected java.lang.String getPluginName()
getPluginName in class AbstractSurefireMojoprotected java.lang.String[] getDefaultIncludes()
getDefaultIncludes in class AbstractSurefireMojopublic boolean isSkipTests()
isSkipTests in interface SurefireExecutionParametersisSkipTests in interface SurefireReportParameterspublic void setSkipTests(boolean skipTests)
setSkipTests in interface SurefireExecutionParameterssetSkipTests in interface SurefireReportParameterspublic boolean isSkipExec()
isSkipExec in interface SurefireExecutionParametersisSkipExec in interface SurefireReportParameterspublic void setSkipExec(boolean skipExec)
setSkipExec in interface SurefireExecutionParameterssetSkipExec in interface SurefireReportParameterspublic boolean isSkip()
isSkip in interface SurefireExecutionParametersisSkip in interface SurefireReportParameterspublic void setSkip(boolean skip)
setSkip in interface SurefireExecutionParameterssetSkip in interface SurefireReportParameterspublic boolean isTestFailureIgnore()
isTestFailureIgnore in interface SurefireReportParameterspublic void setTestFailureIgnore(boolean testFailureIgnore)
setTestFailureIgnore in interface SurefireReportParameterspublic java.io.File getBasedir()
getBasedir in interface SurefireExecutionParametersgetBasedir in interface SurefireReportParameterspublic void setBasedir(java.io.File basedir)
setBasedir in interface SurefireExecutionParameterssetBasedir in interface SurefireReportParameterspublic java.io.File getTestClassesDirectory()
getTestClassesDirectory in interface SurefireExecutionParametersgetTestClassesDirectory in interface SurefireReportParameterspublic void setTestClassesDirectory(java.io.File testClassesDirectory)
setTestClassesDirectory in interface SurefireExecutionParameterssetTestClassesDirectory in interface SurefireReportParameterspublic java.io.File getClassesDirectory()
getClassesDirectory in interface SurefireExecutionParameterspublic void setClassesDirectory(java.io.File classesDirectory)
setClassesDirectory in interface SurefireExecutionParameterspublic java.io.File getReportsDirectory()
getReportsDirectory in interface SurefireExecutionParametersgetReportsDirectory in interface SurefireReportParameterspublic void setReportsDirectory(java.io.File reportsDirectory)
setReportsDirectory in interface SurefireExecutionParameterssetReportsDirectory in interface SurefireReportParameterspublic java.lang.String getTest()
getTest in interface SurefireExecutionParameterspublic boolean isUseSystemClassLoader()
isUseSystemClassLoader in interface SurefireExecutionParameterspublic void setUseSystemClassLoader(boolean useSystemClassLoader)
setUseSystemClassLoader in interface SurefireExecutionParameterspublic boolean isUseManifestOnlyJar()
isUseManifestOnlyJar in interface SurefireExecutionParameterspublic void setUseManifestOnlyJar(boolean useManifestOnlyJar)
setUseManifestOnlyJar in interface SurefireExecutionParameterspublic java.lang.Boolean getFailIfNoSpecifiedTests()
getFailIfNoSpecifiedTests in interface SurefireExecutionParameterspublic void setFailIfNoSpecifiedTests(boolean failIfNoSpecifiedTests)
setFailIfNoSpecifiedTests in interface SurefireExecutionParameterspublic int getSkipAfterFailureCount()
getSkipAfterFailureCount in interface SurefireExecutionParameterspublic java.lang.String getShutdown()
getShutdown in interface SurefireExecutionParameterspublic boolean isPrintSummary()
isPrintSummary in interface SurefireExecutionParameterspublic void setPrintSummary(boolean printSummary)
setPrintSummary in interface SurefireExecutionParameterspublic java.lang.String getReportFormat()
getReportFormat in interface SurefireExecutionParameterspublic void setReportFormat(java.lang.String reportFormat)
setReportFormat in interface SurefireExecutionParameterspublic boolean isUseFile()
isUseFile in interface SurefireExecutionParameterspublic void setUseFile(boolean useFile)
setUseFile in interface SurefireExecutionParameterspublic java.lang.String getDebugForkedProcess()
getDebugForkedProcess in interface SurefireExecutionParameterspublic void setDebugForkedProcess(java.lang.String debugForkedProcess)
setDebugForkedProcess in interface SurefireExecutionParameterspublic int getForkedProcessTimeoutInSeconds()
getForkedProcessTimeoutInSeconds in interface SurefireExecutionParameterspublic void setForkedProcessTimeoutInSeconds(int forkedProcessTimeoutInSeconds)
setForkedProcessTimeoutInSeconds in interface SurefireExecutionParameterspublic double getParallelTestsTimeoutInSeconds()
getParallelTestsTimeoutInSeconds in interface SurefireExecutionParameterspublic void setParallelTestsTimeoutInSeconds(double parallelTestsTimeoutInSeconds)
setParallelTestsTimeoutInSeconds in interface SurefireExecutionParameterspublic double getParallelTestsTimeoutForcedInSeconds()
getParallelTestsTimeoutForcedInSeconds in interface SurefireExecutionParameterspublic void setParallelTestsTimeoutForcedInSeconds(double parallelTestsTimeoutForcedInSeconds)
setParallelTestsTimeoutForcedInSeconds in interface SurefireExecutionParameterspublic void setTest(java.lang.String test)
setTest in interface SurefireExecutionParameterspublic java.util.List<java.lang.String> getIncludes()
getIncludes in interface SurefireExecutionParametersgetIncludes in class AbstractSurefireMojopublic void setIncludes(java.util.List<java.lang.String> includes)
setIncludes in interface SurefireExecutionParameterssetIncludes in class AbstractSurefireMojopublic java.io.File[] getSuiteXmlFiles()
getSuiteXmlFiles in class AbstractSurefireMojopublic void setSuiteXmlFiles(java.io.File[] suiteXmlFiles)
setSuiteXmlFiles in class AbstractSurefireMojopublic java.lang.String getRunOrder()
getRunOrder in class AbstractSurefireMojopublic void setRunOrder(java.lang.String runOrder)
setRunOrder in class AbstractSurefireMojopublic java.io.File getIncludesFile()
getIncludesFile in class AbstractSurefireMojopublic java.io.File getExcludesFile()
getExcludesFile in class AbstractSurefireMojoprotected final java.util.List<java.io.File> suiteXmlFiles()
AbstractSurefireMojoAbstractSurefireMojo.getSuiteXmlFiles() as list.
Never returns null.suiteXmlFiles in class AbstractSurefireMojoprotected final boolean hasSuiteXmlFiles()
hasSuiteXmlFiles in class AbstractSurefireMojosuite-xml files array is not empty.