Package org.apache.maven.plugin.failsafe
Class IntegrationTestMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugin.surefire.AbstractSurefireMojo
org.apache.maven.plugin.failsafe.IntegrationTestMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
,org.apache.maven.plugin.surefire.SurefireExecutionParameters
@Mojo(name="integration-test",
requiresProject=true,
requiresDependencyResolution=TEST,
defaultPhase=INTEGRATION_TEST,
threadSafe=true)
public class IntegrationTestMojo
extends org.apache.maven.plugin.surefire.AbstractSurefireMojo
Run integration tests using Surefire.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate File
The path representing project JAR file, if exists; Otherwise the directory containing generated classes of the project being tested.private String
Attach a debugger to the forked JVM.private File
private String
The character encoding scheme to be applied while generating test report files (see target/surefire-reports/yourTestName.txt).private File
A file containing exclude patterns, each in a next line.private Boolean
Set this to "true" to cause a failure if none of the tests specified in -Dtest=...private static final String
private int
Forked process is normally terminated without any significant delay after given tests have completed.private int
Kill the forked test process after a certain number of seconds.private File
A file containing include patterns, each in a next line.private double
Stop executing queued parallel JUnit tests and interrupt currently running tests after a certain number of seconds.private double
Stop executing queued parallel JUnit tests after a certain number of seconds.private boolean
Option to print summary of test suites or just print the test cases that have errors.private String
Selects the formatting for the test report to be generated.private File
Base directory where all reports are written to.private int
(JUnit 4+ providers) The number of times each failing test will be rerun.private String
Defines the order the tests will be run in.private String
After the plugin process is shutdown by sending SIGTERM signal (CTRL+C), SHUTDOWN command is received by every forked JVM.private int
Set to error/failure count in order to skip remaining tests.private boolean
Set this to "true" to skip running integration tests, but still compile them.private File[]
(TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file locations.private File
The summary file to write integration test results to.private String
private boolean
Option to generate a file test report or just output the test report to the console.private 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.private boolean
Option to pass dependencies to the system's classloader instead of using an isolated class loader when forking.Fields inherited from class org.apache.maven.plugin.surefire.AbstractSurefireMojo
basedir, skip, skipExec, skipTests, testClassesDirectory
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addPluginSpecificChecksumItems
(org.apache.maven.plugin.surefire.booterclient.ChecksumCalculator checksum) protected String[]
int
int
protected org.apache.maven.artifact.Artifact
double
double
protected String
protected String
protected int
int
File[]
getTest()
protected void
handleSummary
(org.apache.maven.surefire.suite.RunResult summary, Exception firstForkException) protected final boolean
private boolean
isJarArtifact
(File artifactFile) boolean
boolean
isSkip()
boolean
Deprecated.protected boolean
boolean
boolean
boolean
boolean
boolean
boolean
void
setBasedir
(File basedir) void
setClassesDirectory
(File classesDirectory) void
setDebugForkedProcess
(String debugForkedProcess) void
setDefaultClassesDirectory
(File defaultClassesDirectory) void
setEncoding
(String encoding) void
setFailIfNoSpecifiedTests
(boolean failIfNoSpecifiedTests) void
setForkedProcessExitTimeoutInSeconds
(int forkedProcessExitTimeoutInSeconds) void
setForkedProcessTimeoutInSeconds
(int forkedProcessTimeoutInSeconds) void
setIncludes
(List<String> includes) void
setParallelTestsTimeoutForcedInSeconds
(double parallelTestsTimeoutForcedInSeconds) void
setParallelTestsTimeoutInSeconds
(double parallelTestsTimeoutInSeconds) void
setPrintSummary
(boolean printSummary) void
setReportFormat
(String reportFormat) void
setReportsDirectory
(File reportsDirectory) void
setRunOrder
(String runOrder) void
setSkip
(boolean skip) void
setSkipExec
(boolean skipExec) Deprecated.void
setSkipITs
(boolean skipITs) void
setSkipTests
(boolean skipTests) void
setSuiteXmlFiles
(File[] suiteXmlFiles) void
setSummaryFile
(File summaryFile) void
void
setTestClassesDirectory
(File testClassesDirectory) void
setTestFailureIgnore
(boolean testFailureIgnore) void
setUseFile
(boolean useFile) void
setUseManifestOnlyJar
(boolean useManifestOnlyJar) void
setUseSystemClassLoader
(boolean useSystemClassLoader) private static File
(package private) static Charset
Methods inherited from class org.apache.maven.plugin.surefire.AbstractSurefireMojo
cleanupForkConfiguration, convertWithCoreCount, createCopyAndReplaceForkNumPlaceholder, createProviders, effectiveIsEnableAssertions, execute, getAdditionalClasspathElements, getArgLine, getArtifactFactory, getArtifactResolver, getClassLoaderConfiguration, getClasspathDependencyExcludes, getClasspathDependencyScopeExclude, getConsoleLogger, getDependenciesToScan, getEffectiveForkCount, getEnvironmentVariables, getExcludedGroups, getExcludes, getFailIfNoTests, getForkCount, getForkMode, getGroups, getJunitArtifactName, getJunitPlatformArtifactName, getJvm, getLocalRepository, getMetadataSource, getObjectFactory, getParallel, getPerCoreThreadCount, getPluginArtifactMap, getPluginDescriptor, getProject, getProjectArtifactMap, getProjectBuildDirectory, getRemoteRepositories, getReportNameSuffix, getSession, getSpecificTests, getStatisticsFile, getSystemProperties, getSystemPropertiesFile, getSystemPropertyVariables, getTempDir, getTestNGArtifactName, getTestSourceDirectory, getThreadCount, getThreadCountClasses, getThreadCountMethods, getThreadCountSuites, getToolchainManager, getUseUnlimitedThreads, getWorkingDirectory, hasExecutedBefore, isAnyConcurrencySelected, isAnyGroupsSelected, isChildDelegation, isDisableXmlReport, isEnableAssertions, isForking, isMavenParallel, isParallelOptimized, isRedirectTestOutputToFile, isReuseForks, isTrimStackTrace, logDebugOrCliShowErrors, logReportsDirectory, setAdditionalClasspathElements, setArgLine, setArtifactFactory, setArtifactResolver, setChildDelegation, setClasspathDependencyExcludes, setClasspathDependencyScopeExclude, setDependenciesToScan, setDisableXmlReport, setEnableAssertions, setEnvironmentVariables, setExcludedGroups, setExcludes, setFailIfNoTests, setForkMode, setGroups, setJunitArtifactName, setJunitPlatformArtifactName, setLocalRepository, setMetadataSource, setObjectFactory, setParallel, setParallelOptimized, setPerCoreThreadCount, setPluginArtifactMap, setProject, setProjectArtifactMap, setProjectBuildDirectory, setProperties, setRedirectTestOutputToFile, setRemoteRepositories, setReportNameSuffix, setSession, setSystemProperties, setSystemPropertiesFile, setSystemPropertyVariables, setTempDir, setTestNGArtifactName, setTestSourceDirectory, setThreadCount, setThreadCountClasses, setThreadCountMethods, setThreadCountSuites, setToolchainManager, setTrimStackTrace, setUseUnlimitedThreads, setWorkingDirectory
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
FAILSAFE_IN_PROGRESS_CONTEXT_KEY
- See Also:
-
classesDirectory
The path representing project JAR file, if exists; Otherwise the directory containing generated classes of the project being tested. This will be included after the test classes in the test classpath. Defaults to built artifact JAR file or${project.build.outputDirectory}
. -
defaultClassesDirectory
@Parameter(readonly=true, defaultValue="${project.build.outputDirectory}") private File defaultClassesDirectory -
skipITs
@Parameter(property="skipITs") private boolean skipITsSet this to "true" to skip running integration tests, but still compile them. Its use is NOT RECOMMENDED, but quite convenient on occasion.- Since:
- 2.4.3-alpha-2
-
reportsDirectory
@Parameter(defaultValue="${project.build.directory}/failsafe-reports") private File reportsDirectoryBase directory where all reports are written to. -
test
-
summaryFile
@Parameter(defaultValue="${project.build.directory}/failsafe-reports/failsafe-summary.xml", required=true) private File summaryFileThe summary file to write integration test results to. -
printSummary
@Parameter(property="failsafe.printSummary", defaultValue="true") private boolean printSummaryOption to print summary of test suites or just print the test cases that have errors. -
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="failsafe.useFile", defaultValue="true") private boolean useFileOption to generate a file test report or just output the test report to the console. -
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
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 debugging ability options (without overwriting the other options specified through theargLine
parameter).- Since:
- 2.4
-
forkedProcessTimeoutInSeconds
@Parameter(property="failsafe.timeout") private int forkedProcessTimeoutInSecondsKill 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="failsafe.exitTimeout", defaultValue="30") private int forkedProcessExitTimeoutInSecondsForked 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-failsafe-plugin/examples/shutdown.html- Since:
- 2.20
-
parallelTestsTimeoutInSeconds
@Parameter(property="failsafe.parallel.timeout") private double parallelTestsTimeoutInSecondsStop 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="failsafe.parallel.forcedTimeout") private double parallelTestsTimeoutForcedInSecondsStop executing queued parallel JUnit tests and interrupt 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
-
useSystemClassLoader
@Parameter(property="failsafe.useSystemClassLoader", defaultValue="true") private boolean useSystemClassLoaderOption 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="failsafe.useManifestOnlyJar", defaultValue="true") private boolean useManifestOnlyJarBy 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-failsafe-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="encoding", defaultValue="${project.reporting.outputEncoding}") private String encodingThe character encoding scheme to be applied while generating test report files (see target/surefire-reports/yourTestName.txt). The report output files (*-out.txt) are still encoded with JVM's encoding used in standard out/err pipes.- Since:
- 3.0.0-M1
-
rerunFailingTestsCount
@Parameter(property="failsafe.rerunFailingTestsCount", defaultValue="0") private int rerunFailingTestsCount(JUnit 4+ providers) 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. -
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
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
-
includesFile
A file containing include patterns, each in a next line. Blank lines, or lines starting with # are ignored. Ifincludes
are also specified, these patterns are appended. Example with path, simple and regex includes:*/it/* **/NotIncludedByDefault.java %regex[.*IT.*|.*Not.*]
-
excludesFile
A file containing exclude patterns, each in a next line. Blank lines, or lines starting with # are ignored. Ifexcludes
are also specified, these patterns are appended. Example with path, simple and regex excludes:*/it/* **/DontRunIT.* %regex[.*IT.*|.*Not.*]
-
skipAfterFailureCount
@Parameter(property="failsafe.skipAfterFailureCount", defaultValue="0") private int skipAfterFailureCountSet 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-Dfailsafe.skipAfterFailureCount=1
or any number greater than zero. Defaults to "0".
See the prerequisites and limitations in documentation:
http://maven.apache.org/plugins/maven-failsafe-plugin/examples/skip-after-failure.html- Since:
- 2.19
-
shutdown
After the plugin process is shutdown by sending SIGTERM signal (CTRL+C), SHUTDOWN command is received by every forked JVM.
By default (shutdown=testset
) forked JVM would not continue with new test which means that the current test may still continue to run.
The parameter can be configured with other two valuesexit
andkill
.
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
-
-
Constructor Details
-
IntegrationTestMojo
public IntegrationTestMojo()
-
-
Method Details
-
getRerunFailingTestsCount
protected int getRerunFailingTestsCount()- Specified by:
getRerunFailingTestsCount
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
handleSummary
protected void handleSummary(org.apache.maven.surefire.suite.RunResult summary, 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
-
isJarArtifact
-
toAbsoluteCanonical
-
isSkipExecution
protected boolean isSkipExecution()- Specified by:
isSkipExecution
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getPluginName
- Specified by:
getPluginName
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getDefaultIncludes
- Specified by:
getDefaultIncludes
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getReportSchemaLocation
- Specified by:
getReportSchemaLocation
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getMojoArtifact
protected org.apache.maven.artifact.Artifact getMojoArtifact()- Specified by:
getMojoArtifact
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
isSkipTests
public boolean isSkipTests() -
setSkipTests
public void setSkipTests(boolean skipTests) -
isSkipITs
public boolean isSkipITs() -
setSkipITs
public void setSkipITs(boolean skipITs) -
isSkipExec
Deprecated. -
setSkipExec
Deprecated. -
isSkip
public boolean isSkip() -
setSkip
public void setSkip(boolean skip) -
getBasedir
-
setBasedir
-
getTestClassesDirectory
-
setTestClassesDirectory
-
getClassesDirectory
- Returns:
- Output directory, or artifact file if artifact type is "jar". If not forking the JVM, parameter
useSystemClassLoader
is ignored and theIsolatedClassLoader
is used instead. See the resolution ofClassLoaderConfiguration
.
-
setClassesDirectory
-
setDefaultClassesDirectory
-
getReportsDirectory
-
setReportsDirectory
-
getTest
-
setTest
-
getSummaryFile
-
setSummaryFile
-
isPrintSummary
public boolean isPrintSummary() -
setPrintSummary
public void setPrintSummary(boolean printSummary) -
getReportFormat
-
setReportFormat
-
isUseFile
public boolean isUseFile() -
setUseFile
public void setUseFile(boolean useFile) -
getDebugForkedProcess
-
setDebugForkedProcess
-
getForkedProcessTimeoutInSeconds
public int getForkedProcessTimeoutInSeconds() -
setForkedProcessTimeoutInSeconds
public void setForkedProcessTimeoutInSeconds(int forkedProcessTimeoutInSeconds) -
getForkedProcessExitTimeoutInSeconds
public int getForkedProcessExitTimeoutInSeconds() -
setForkedProcessExitTimeoutInSeconds
public void setForkedProcessExitTimeoutInSeconds(int forkedProcessExitTimeoutInSeconds) -
getParallelTestsTimeoutInSeconds
public double getParallelTestsTimeoutInSeconds() -
setParallelTestsTimeoutInSeconds
public void setParallelTestsTimeoutInSeconds(double parallelTestsTimeoutInSeconds) -
getParallelTestsTimeoutForcedInSeconds
public double getParallelTestsTimeoutForcedInSeconds() -
setParallelTestsTimeoutForcedInSeconds
public void setParallelTestsTimeoutForcedInSeconds(double parallelTestsTimeoutForcedInSeconds) -
isUseSystemClassLoader
public boolean isUseSystemClassLoader() -
setUseSystemClassLoader
public void setUseSystemClassLoader(boolean useSystemClassLoader) -
isUseManifestOnlyJar
public boolean isUseManifestOnlyJar() -
setUseManifestOnlyJar
public void setUseManifestOnlyJar(boolean useManifestOnlyJar) -
getEncoding
-
setEncoding
-
isTestFailureIgnore
public boolean isTestFailureIgnore() -
setTestFailureIgnore
public void setTestFailureIgnore(boolean testFailureIgnore) -
addPluginSpecificChecksumItems
protected void addPluginSpecificChecksumItems(org.apache.maven.plugin.surefire.booterclient.ChecksumCalculator checksum) - Overrides:
addPluginSpecificChecksumItems
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getFailIfNoSpecifiedTests
-
setFailIfNoSpecifiedTests
public void setFailIfNoSpecifiedTests(boolean failIfNoSpecifiedTests) -
getSkipAfterFailureCount
public int getSkipAfterFailureCount() -
getShutdown
-
getIncludes
- Specified by:
getIncludes
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
getIncludes
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
setIncludes
- Specified by:
setIncludes
in interfaceorg.apache.maven.plugin.surefire.SurefireExecutionParameters
- Specified by:
setIncludes
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getSuiteXmlFiles
- Specified by:
getSuiteXmlFiles
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
setSuiteXmlFiles
- Specified by:
setSuiteXmlFiles
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getRunOrder
- Specified by:
getRunOrder
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
setRunOrder
- Specified by:
setRunOrder
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getIncludesFile
- Specified by:
getIncludesFile
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
getExcludesFile
- Specified by:
getExcludesFile
in classorg.apache.maven.plugin.surefire.AbstractSurefireMojo
-
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
-
toCharset
-