@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, verifyParameters
getLog, getPluginContext, setLog, setPluginContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFailIfNoTests, 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 AbstractSurefireMojo
protected void handleSummary(RunResult summary, java.lang.Exception firstForkException) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
handleSummary
in class AbstractSurefireMojo
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
private void assertNoException(java.lang.Exception firstForkException) throws org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoFailureException
protected boolean isSkipExecution()
isSkipExecution
in class AbstractSurefireMojo
protected java.lang.String getPluginName()
getPluginName
in class AbstractSurefireMojo
protected java.lang.String[] getDefaultIncludes()
getDefaultIncludes
in class AbstractSurefireMojo
public boolean isSkipTests()
isSkipTests
in interface SurefireExecutionParameters
isSkipTests
in interface SurefireReportParameters
public void setSkipTests(boolean skipTests)
setSkipTests
in interface SurefireExecutionParameters
setSkipTests
in interface SurefireReportParameters
public boolean isSkipExec()
isSkipExec
in interface SurefireExecutionParameters
isSkipExec
in interface SurefireReportParameters
public void setSkipExec(boolean skipExec)
setSkipExec
in interface SurefireExecutionParameters
setSkipExec
in interface SurefireReportParameters
public boolean isSkip()
isSkip
in interface SurefireExecutionParameters
isSkip
in interface SurefireReportParameters
public void setSkip(boolean skip)
setSkip
in interface SurefireExecutionParameters
setSkip
in interface SurefireReportParameters
public boolean isTestFailureIgnore()
isTestFailureIgnore
in interface SurefireReportParameters
public void setTestFailureIgnore(boolean testFailureIgnore)
setTestFailureIgnore
in interface SurefireReportParameters
public java.io.File getBasedir()
getBasedir
in interface SurefireExecutionParameters
getBasedir
in interface SurefireReportParameters
public void setBasedir(java.io.File basedir)
setBasedir
in interface SurefireExecutionParameters
setBasedir
in interface SurefireReportParameters
public java.io.File getTestClassesDirectory()
getTestClassesDirectory
in interface SurefireExecutionParameters
getTestClassesDirectory
in interface SurefireReportParameters
public void setTestClassesDirectory(java.io.File testClassesDirectory)
setTestClassesDirectory
in interface SurefireExecutionParameters
setTestClassesDirectory
in interface SurefireReportParameters
public java.io.File getClassesDirectory()
getClassesDirectory
in interface SurefireExecutionParameters
public void setClassesDirectory(java.io.File classesDirectory)
setClassesDirectory
in interface SurefireExecutionParameters
public java.io.File getReportsDirectory()
getReportsDirectory
in interface SurefireExecutionParameters
getReportsDirectory
in interface SurefireReportParameters
public void setReportsDirectory(java.io.File reportsDirectory)
setReportsDirectory
in interface SurefireExecutionParameters
setReportsDirectory
in interface SurefireReportParameters
public java.lang.String getTest()
getTest
in interface SurefireExecutionParameters
public boolean isUseSystemClassLoader()
isUseSystemClassLoader
in interface SurefireExecutionParameters
public void setUseSystemClassLoader(boolean useSystemClassLoader)
setUseSystemClassLoader
in interface SurefireExecutionParameters
public boolean isUseManifestOnlyJar()
isUseManifestOnlyJar
in interface SurefireExecutionParameters
public void setUseManifestOnlyJar(boolean useManifestOnlyJar)
setUseManifestOnlyJar
in interface SurefireExecutionParameters
public java.lang.Boolean getFailIfNoSpecifiedTests()
getFailIfNoSpecifiedTests
in interface SurefireExecutionParameters
public void setFailIfNoSpecifiedTests(boolean failIfNoSpecifiedTests)
setFailIfNoSpecifiedTests
in interface SurefireExecutionParameters
public int getSkipAfterFailureCount()
getSkipAfterFailureCount
in interface SurefireExecutionParameters
public java.lang.String getShutdown()
getShutdown
in interface SurefireExecutionParameters
public boolean isPrintSummary()
isPrintSummary
in interface SurefireExecutionParameters
public void setPrintSummary(boolean printSummary)
setPrintSummary
in interface SurefireExecutionParameters
public java.lang.String getReportFormat()
getReportFormat
in interface SurefireExecutionParameters
public void setReportFormat(java.lang.String reportFormat)
setReportFormat
in interface SurefireExecutionParameters
public boolean isUseFile()
isUseFile
in interface SurefireExecutionParameters
public void setUseFile(boolean useFile)
setUseFile
in interface SurefireExecutionParameters
public java.lang.String getDebugForkedProcess()
getDebugForkedProcess
in interface SurefireExecutionParameters
public void setDebugForkedProcess(java.lang.String debugForkedProcess)
setDebugForkedProcess
in interface SurefireExecutionParameters
public int getForkedProcessTimeoutInSeconds()
getForkedProcessTimeoutInSeconds
in interface SurefireExecutionParameters
public void setForkedProcessTimeoutInSeconds(int forkedProcessTimeoutInSeconds)
setForkedProcessTimeoutInSeconds
in interface SurefireExecutionParameters
public double getParallelTestsTimeoutInSeconds()
getParallelTestsTimeoutInSeconds
in interface SurefireExecutionParameters
public void setParallelTestsTimeoutInSeconds(double parallelTestsTimeoutInSeconds)
setParallelTestsTimeoutInSeconds
in interface SurefireExecutionParameters
public double getParallelTestsTimeoutForcedInSeconds()
getParallelTestsTimeoutForcedInSeconds
in interface SurefireExecutionParameters
public void setParallelTestsTimeoutForcedInSeconds(double parallelTestsTimeoutForcedInSeconds)
setParallelTestsTimeoutForcedInSeconds
in interface SurefireExecutionParameters
public void setTest(java.lang.String test)
setTest
in interface SurefireExecutionParameters
public java.util.List<java.lang.String> getIncludes()
getIncludes
in interface SurefireExecutionParameters
getIncludes
in class AbstractSurefireMojo
public void setIncludes(java.util.List<java.lang.String> includes)
setIncludes
in interface SurefireExecutionParameters
setIncludes
in class AbstractSurefireMojo
public java.io.File[] getSuiteXmlFiles()
getSuiteXmlFiles
in class AbstractSurefireMojo
public void setSuiteXmlFiles(java.io.File[] suiteXmlFiles)
setSuiteXmlFiles
in class AbstractSurefireMojo
public java.lang.String getRunOrder()
getRunOrder
in class AbstractSurefireMojo
public void setRunOrder(java.lang.String runOrder)
setRunOrder
in class AbstractSurefireMojo
public java.io.File getIncludesFile()
getIncludesFile
in class AbstractSurefireMojo
public java.io.File getExcludesFile()
getExcludesFile
in class AbstractSurefireMojo
protected final java.util.List<java.io.File> suiteXmlFiles()
AbstractSurefireMojo
AbstractSurefireMojo.getSuiteXmlFiles()
as list
.
Never returns null.suiteXmlFiles
in class AbstractSurefireMojo
protected final boolean hasSuiteXmlFiles()
hasSuiteXmlFiles
in class AbstractSurefireMojo
suite-xml files array
is not empty.