Class IntegrationTestMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo, SurefireExecutionParameters

    @Mojo(name="integration-test",
          requiresProject=true,
          requiresDependencyResolution=TEST,
          defaultPhase=INTEGRATION_TEST,
          threadSafe=true)
    public class IntegrationTestMojo
    extends AbstractSurefireMojo
    Run integration tests using Surefire.
    • Field Detail

      • FAILSAFE_IN_PROGRESS_CONTEXT_KEY

        private static final java.lang.String FAILSAFE_IN_PROGRESS_CONTEXT_KEY
        See Also:
        Constant Field Values
      • classesDirectory

        @Parameter
        private java.io.File 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(defaultValue="${project.build.outputDirectory}",
                   readonly=true,
                   required=true)
        private java.io.File defaultClassesDirectory
      • skipITs

        @Parameter(property="skipITs")
        private boolean skipITs
        Set 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 java.io.File reportsDirectory
        Base directory where all reports are written to.
      • test

        @Parameter(property="it.test")
        private java.lang.String test
      • summaryFile

        @Parameter(defaultValue="${project.build.directory}/failsafe-reports/failsafe-summary.xml",
                   required=true)
        private java.io.File summaryFile
        The summary file to write integration test results to.
      • printSummary

        @Parameter(property="failsafe.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="failsafe.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="failsafe.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="it.failIfNoSpecifiedTests")
        private java.lang.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.failsafe.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 debugging ability options (without overwriting the other options specified through the argLine parameter).
        Since:
        2.4
      • forkedProcessTimeoutInSeconds

        @Parameter(property="failsafe.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="failsafe.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 by System.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 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 specified parallel different from "none".
        Since:
        2.16
      • parallelTestsTimeoutForcedInSeconds

        @Parameter(property="failsafe.parallel.forcedTimeout")
        private double parallelTestsTimeoutForcedInSeconds
        Stop 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 specified parallel different from "none".
        Since:
        2.16
      • includes

        @Parameter
        private java.util.List<java.lang.String> includes
      • useSystemClassLoader

        @Parameter(property="failsafe.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="failsafe.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-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 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 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 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.
      • suiteXmlFiles

        @Parameter(property="failsafe.suiteXmlFiles")
        private java.io.File[] suiteXmlFiles
        (TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file locations. Note that suiteXmlFiles is incompatible with several other parameters of this plugin, like includes and excludes.
        This parameter is ignored if the test parameter is specified (allowing you to run a single test instead of an entire suite).
        Since:
        2.2
      • runOrder

        @Parameter(property="failsafe.runOrder",
                   defaultValue="filesystem")
        private java.lang.String runOrder
        Defines the order the tests will be run in. Supported values are alphabetical, reversealphabetical, random, hourly (alphabetical on even hours, reverse alphabetical on odd hours), failedfirst, balanced and filesystem.

        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

        @Parameter(property="failsafe.includesFile")
        private java.io.File includesFile
        A file containing include patterns, each in a next line. Blank lines, or lines starting with # are ignored. If includes are also specified, these patterns are appended. Example with path, simple and regex includes:
        
         */it/*
         **/NotIncludedByDefault.java
         %regex[.*IT.*|.*Not.*]
         
        Since:
        2.13
      • excludesFile

        @Parameter(property="failsafe.excludesFile")
        private java.io.File excludesFile
        A file containing exclude patterns, each in a next line. Blank lines, or lines starting with # are ignored. If excludes are also specified, these patterns are appended. Example with path, simple and regex excludes:
        
         */it/*
         **/DontRunIT.*
         %regex[.*IT.*|.*Not.*]
         
        Since:
        2.13
      • skipAfterFailureCount

        @Parameter(property="failsafe.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 -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

        @Parameter(property="failsafe.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 values testset and kill.
        With(shutdown=testset) the test set may still continue to run in forked JVM.
        Using exit forked JVM executes System.exit(1) after the plugin process has received SIGTERM signal.
        Using kill the JVM executes Runtime.halt(1) and kills itself.
        Since:
        2.19
      • useModulePath

        @Parameter(property="failsafe.useModulePath",
                   defaultValue="true")
        private boolean useModulePath
        Disables modular path (aka Jigsaw project since of Java 9) even if module-info.java is used in project.
        Enabled by default. If enabled, module-info.java exists and executes with JDK 9+, modular path is used.
        Since:
        3.0.0-M2
      • excludedEnvironmentVariables

        @Parameter(property="failsafe.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 -Dfailsafe.excludedEnvironmentVariables=ACME1,ACME2,ACME3
        Since:
        3.0.0-M4
      • enableProcessChecker

        @Parameter(property="failsafe.enableProcessChecker")
        private java.lang.String enableProcessChecker
        Since 3.0.0-M4 the process checkers are disabled. You can enable them namely by setting ping and native or all in this parameter.
        The checker is useful in situations when you kill the build on CI 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.
        The ping should be safely used together with ZGC or Shenandoah Garbage Collector. Due to the ping relies on timing of PING (triggered every 30 seconds), slow GC may pause the timers and pretend that the parent process of the fork JVM does not exist.
        The native 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 is forkedProcessTimeoutInSeconds.
        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
    • Constructor Detail

      • IntegrationTestMojo

        public IntegrationTestMojo()
    • Method Detail

      • handleSummary

        protected void handleSummary​(RunResult summary,
                                     java.lang.Exception firstForkException)
                              throws org.apache.maven.plugin.MojoExecutionException,
                                     org.apache.maven.plugin.MojoFailureException
        Specified by:
        handleSummary in class AbstractSurefireMojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • isJarArtifact

        private boolean isJarArtifact​(java.io.File artifactFile)
      • toAbsoluteCanonical

        private static java.io.File toAbsoluteCanonical​(java.io.File f)
      • isSkipTests

        public boolean isSkipTests()
      • setSkipTests

        @Deprecated
        public void setSkipTests​(boolean skipTests)
        Deprecated.
      • isSkipITs

        public boolean isSkipITs()
      • setSkipITs

        public void setSkipITs​(boolean skipITs)
      • isSkipExec

        @Deprecated
        public boolean isSkipExec()
        Deprecated.
      • setSkipExec

        @Deprecated
        public void setSkipExec​(boolean skipExec)
        Deprecated.
      • isSkip

        public boolean isSkip()
      • setSkip

        public void setSkip​(boolean skip)
      • getBasedir

        public java.io.File getBasedir()
      • setBasedir

        public void setBasedir​(java.io.File basedir)
      • getTestClassesDirectory

        public java.io.File getTestClassesDirectory()
      • setTestClassesDirectory

        public void setTestClassesDirectory​(java.io.File testClassesDirectory)
      • setClassesDirectory

        public void setClassesDirectory​(java.io.File classesDirectory)
      • setDefaultClassesDirectory

        public void setDefaultClassesDirectory​(java.io.File defaultClassesDirectory)
      • getReportsDirectory

        public java.io.File getReportsDirectory()
      • setReportsDirectory

        public void setReportsDirectory​(java.io.File reportsDirectory)
      • getTest

        public java.lang.String getTest()
      • setTest

        public void setTest​(java.lang.String test)
      • getSummaryFile

        public java.io.File getSummaryFile()
      • setSummaryFile

        public void setSummaryFile​(java.io.File summaryFile)
      • isPrintSummary

        public boolean isPrintSummary()
      • setPrintSummary

        public void setPrintSummary​(boolean printSummary)
      • getReportFormat

        public java.lang.String getReportFormat()
      • setReportFormat

        public void setReportFormat​(java.lang.String reportFormat)
      • isUseFile

        public boolean isUseFile()
      • setUseFile

        public void setUseFile​(boolean useFile)
      • getDebugForkedProcess

        public java.lang.String getDebugForkedProcess()
      • setDebugForkedProcess

        public void setDebugForkedProcess​(java.lang.String debugForkedProcess)
      • 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

        public java.lang.String getEncoding()
      • setEncoding

        public void setEncoding​(java.lang.String encoding)
      • isTestFailureIgnore

        public boolean isTestFailureIgnore()
      • setTestFailureIgnore

        public void setTestFailureIgnore​(boolean testFailureIgnore)
      • getFailIfNoSpecifiedTests

        public java.lang.Boolean getFailIfNoSpecifiedTests()
      • setFailIfNoSpecifiedTests

        public void setFailIfNoSpecifiedTests​(boolean failIfNoSpecifiedTests)
      • getSkipAfterFailureCount

        public int getSkipAfterFailureCount()
      • getShutdown

        public java.lang.String getShutdown()
      • setExcludedEnvironmentVariables

        void setExcludedEnvironmentVariables​(java.lang.String[] excludedEnvironmentVariables)