Class AbstractSurefireMojo

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

    public abstract class AbstractSurefireMojo
    extends org.apache.maven.plugin.AbstractMojo
    implements SurefireExecutionParameters
    Abstract base class for running tests using Surefire.
    Author:
    Stephen Connolly
    • Field Detail

      • skipTests

        @Parameter(property="skipTests",
                   defaultValue="false")
        protected boolean skipTests
        Set this to "true" to skip running tests, but still compile them. Its use is NOT RECOMMENDED, but quite convenient on occasion.
        Failsafe plugin deprecated the parameter skipTests and the parameter will be removed in Failsafe 3.0.0 as it is a source of conflicts between Failsafe and Surefire plugin.
        Since:
        2.4
      • skipExec

        @Deprecated
        @Parameter(property="maven.test.skip.exec")
        protected boolean skipExec
        Deprecated.
        Use skipTests instead.
        This old parameter is just like skipTests, but bound to the old property "maven.test.skip.exec".
        Since:
        2.3
      • skip

        @Parameter(property="maven.test.skip",
                   defaultValue="false")
        protected boolean skip
        Set this to "true" to bypass unit tests entirely. Its use is NOT RECOMMENDED, especially if you enable it using the "maven.test.skip" property, because maven.test.skip disables both running the tests and compiling the tests. Consider using the skipTests parameter instead.
      • basedir

        @Parameter(defaultValue="${basedir}",
                   readonly=true,
                   required=true)
        protected java.io.File basedir
        The base directory of the project being tested. This can be obtained in your integration test via System.getProperty("basedir").
      • testClassesDirectory

        @Parameter(defaultValue="${project.build.testOutputDirectory}")
        protected java.io.File testClassesDirectory
        The directory containing generated test classes of the project being tested. This will be included at the beginning of the test classpath.
    • Constructor Detail

      • AbstractSurefireMojo

        public AbstractSurefireMojo()
    • Method Detail

      • getPluginName

        protected abstract java.lang.String getPluginName()
      • getRerunFailingTestsCount

        protected abstract int getRerunFailingTestsCount()
      • getIncludesFile

        public abstract java.io.File getIncludesFile()
      • getExcludesFile

        public abstract java.io.File getExcludesFile()
      • suiteXmlFiles

        protected abstract java.util.List<java.io.File> suiteXmlFiles()
        Calls getSuiteXmlFiles() as list. Never returns null.
        Returns:
        list of TestNG suite XML files provided by MOJO
      • hasSuiteXmlFiles

        protected abstract boolean hasSuiteXmlFiles()
        Returns:
        true if suite-xml files array is not empty.
      • getExcludedEnvironmentVariables

        protected abstract java.lang.String[] getExcludedEnvironmentVariables()
      • getSuiteXmlFiles

        public abstract java.io.File[] getSuiteXmlFiles()
      • setSuiteXmlFiles

        public abstract void setSuiteXmlFiles​(java.io.File[] suiteXmlFiles)
      • getRunOrder

        public abstract java.lang.String getRunOrder()
      • setRunOrder

        public abstract void setRunOrder​(java.lang.String runOrder)
      • getRunOrderRandomSeed

        public abstract java.lang.Long getRunOrderRandomSeed()
      • setRunOrderRandomSeed

        public abstract void setRunOrderRandomSeed​(java.lang.Long runOrderRandomSeed)
      • handleSummary

        protected abstract 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
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • isSkipExecution

        protected abstract boolean isSkipExecution()
      • getDefaultIncludes

        protected abstract java.lang.String[] getDefaultIncludes()
      • getReportSchemaLocation

        protected abstract java.lang.String getReportSchemaLocation()
      • useModulePath

        protected abstract boolean useModulePath()
      • setUseModulePath

        protected abstract void setUseModulePath​(boolean useModulePath)
      • getEnableProcessChecker

        protected abstract java.lang.String getEnableProcessChecker()
      • getForkNode

        protected abstract org.apache.maven.surefire.extensions.ForkNodeFactory getForkNode()
      • getMojoArtifact

        protected org.apache.maven.artifact.Artifact getMojoArtifact()
        This plugin MOJO artifact.
        Returns:
        non-null plugin artifact
      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException,
                            org.apache.maven.plugin.MojoFailureException
        Specified by:
        execute in interface org.apache.maven.plugin.Mojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • createProviders

        protected java.util.List<ProviderInfo> createProviders​(org.apache.maven.plugin.surefire.TestClassPath testClasspath)
                                                        throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • createCopyAndReplaceForkNumPlaceholder

        public static SurefireProperties createCopyAndReplaceForkNumPlaceholder​(SurefireProperties effectiveSystemProperties,
                                                                                int threadNumber)
      • cleanupForkConfiguration

        protected void cleanupForkConfiguration​(ForkConfiguration forkConfiguration)
      • logReportsDirectory

        protected void logReportsDirectory()
      • isAnyConcurrencySelected

        protected boolean isAnyConcurrencySelected()
      • isAnyGroupsSelected

        protected boolean isAnyGroupsSelected()
      • isForking

        protected boolean isForking()
      • getSpecificTests

        public org.apache.maven.surefire.api.testset.TestListResolver getSpecificTests()
                                                                                throws org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoFailureException
      • getEffectiveForkCount

        protected int getEffectiveForkCount()
      • convertWithCoreCount

        protected int convertWithCoreCount​(java.lang.String count)
      • addPluginSpecificChecksumItems

        protected void addPluginSpecificChecksumItems​(ChecksumCalculator checksum)
      • hasExecutedBefore

        protected boolean hasExecutedBefore()
      • getClassLoaderConfiguration

        @Nonnull
        protected org.apache.maven.surefire.booter.ClassLoaderConfiguration getClassLoaderConfiguration()
      • resolveDependencies

        protected java.util.Collection<org.apache.maven.artifact.Artifact> resolveDependencies​(java.util.List<org.apache.maven.model.Dependency> dependencies)
                                                                                        throws org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoFailureException
      • warnIfIllegalFailOnFlakeCount

        protected void warnIfIllegalFailOnFlakeCount()
                                              throws org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoFailureException
      • getSystemProperties

        public java.util.Properties getSystemProperties()
      • setSystemProperties

        public void setSystemProperties​(java.util.Properties systemProperties)
      • getSystemPropertyVariables

        public java.util.Map<java.lang.String,​java.lang.String> getSystemPropertyVariables()
      • setSystemPropertyVariables

        public void setSystemPropertyVariables​(java.util.Map<java.lang.String,​java.lang.String> systemPropertyVariables)
      • getSystemPropertiesFile

        public abstract java.io.File getSystemPropertiesFile()
        List of System properties, loaded from a file, to pass to the JUnit tests.
        Since:
        2.8.2
      • setSystemPropertiesFile

        public abstract void setSystemPropertiesFile​(java.io.File systemPropertiesFile)
      • setProperties

        public void setProperties​(java.util.Properties properties)
      • getPluginArtifactMap

        public java.util.Map<java.lang.String,​org.apache.maven.artifact.Artifact> getPluginArtifactMap()
      • setPluginArtifactMap

        public void setPluginArtifactMap​(java.util.Map<java.lang.String,​org.apache.maven.artifact.Artifact> pluginArtifactMap)
      • getProjectArtifactMap

        public java.util.Map<java.lang.String,​org.apache.maven.artifact.Artifact> getProjectArtifactMap()
      • setProjectArtifactMap

        public void setProjectArtifactMap​(java.util.Map<java.lang.String,​org.apache.maven.artifact.Artifact> projectArtifactMap)
      • getReportNameSuffix

        public java.lang.String getReportNameSuffix()
      • setReportNameSuffix

        public void setReportNameSuffix​(java.lang.String reportNameSuffix)
      • isRedirectTestOutputToFile

        public boolean isRedirectTestOutputToFile()
      • setRedirectTestOutputToFile

        public void setRedirectTestOutputToFile​(boolean redirectTestOutputToFile)
      • getFailIfNoTests

        public boolean getFailIfNoTests()
      • setFailIfNoTests

        public void setFailIfNoTests​(boolean failIfNoTests)
      • getJvm

        public java.lang.String getJvm()
      • getArgLine

        public java.lang.String getArgLine()
      • setArgLine

        public void setArgLine​(java.lang.String argLine)
      • getEnvironmentVariables

        public java.util.Map<java.lang.String,​java.lang.String> getEnvironmentVariables()
      • setEnvironmentVariables

        public void setEnvironmentVariables​(java.util.Map<java.lang.String,​java.lang.String> environmentVariables)
      • getWorkingDirectory

        public java.io.File getWorkingDirectory()
      • setWorkingDirectory

        public void setWorkingDirectory​(java.io.File workingDirectory)
      • isChildDelegation

        public boolean isChildDelegation()
      • setChildDelegation

        public void setChildDelegation​(boolean childDelegation)
      • getGroups

        public java.lang.String getGroups()
      • setGroups

        public void setGroups​(java.lang.String groups)
      • getExcludedGroups

        public java.lang.String getExcludedGroups()
      • setExcludedGroups

        public void setExcludedGroups​(java.lang.String excludedGroups)
      • getJunitArtifactName

        public java.lang.String getJunitArtifactName()
      • setJunitArtifactName

        public void setJunitArtifactName​(java.lang.String junitArtifactName)
      • getTestNGArtifactName

        public java.lang.String getTestNGArtifactName()
      • setTestNGArtifactName

        public void setTestNGArtifactName​(java.lang.String testNGArtifactName)
      • getThreadCount

        public int getThreadCount()
      • setThreadCount

        public void setThreadCount​(int threadCount)
      • getPerCoreThreadCount

        public boolean getPerCoreThreadCount()
      • setPerCoreThreadCount

        public void setPerCoreThreadCount​(boolean perCoreThreadCount)
      • getUseUnlimitedThreads

        public boolean getUseUnlimitedThreads()
      • setUseUnlimitedThreads

        public void setUseUnlimitedThreads​(boolean useUnlimitedThreads)
      • getParallel

        public java.lang.String getParallel()
      • setParallel

        public void setParallel​(java.lang.String parallel)
      • isParallelOptimized

        public boolean isParallelOptimized()
      • setParallelOptimized

        public void setParallelOptimized​(boolean parallelOptimized)
      • getThreadCountSuites

        public int getThreadCountSuites()
      • setThreadCountSuites

        public void setThreadCountSuites​(int threadCountSuites)
      • getThreadCountClasses

        public int getThreadCountClasses()
      • setThreadCountClasses

        public void setThreadCountClasses​(int threadCountClasses)
      • getThreadCountMethods

        public int getThreadCountMethods()
      • setThreadCountMethods

        public void setThreadCountMethods​(int threadCountMethods)
      • isTrimStackTrace

        public boolean isTrimStackTrace()
      • setTrimStackTrace

        public void setTrimStackTrace​(boolean trimStackTrace)
      • isDisableXmlReport

        public java.lang.Boolean isDisableXmlReport()
      • setDisableXmlReport

        public void setDisableXmlReport​(java.lang.Boolean disableXmlReport)
      • isEnableAssertions

        public boolean isEnableAssertions()
      • effectiveIsEnableAssertions

        public boolean effectiveIsEnableAssertions()
      • setEnableAssertions

        public void setEnableAssertions​(boolean enableAssertions)
      • isEnableOutErrElements

        public boolean isEnableOutErrElements()
      • setEnableOutErrElements

        public void setEnableOutErrElements​(boolean enableOutErrElements)
      • isEnablePropertiesElement

        public boolean isEnablePropertiesElement()
      • setEnablePropertiesElement

        public void setEnablePropertiesElement​(boolean enablePropertiesElement)
      • getSession

        public org.apache.maven.execution.MavenSession getSession()
      • setSession

        public void setSession​(org.apache.maven.execution.MavenSession session)
      • getObjectFactory

        public java.lang.String getObjectFactory()
      • setObjectFactory

        public void setObjectFactory​(java.lang.String objectFactory)
      • getToolchainManager

        public org.apache.maven.toolchain.ToolchainManager getToolchainManager()
      • setToolchainManager

        public void setToolchainManager​(org.apache.maven.toolchain.ToolchainManager toolchainManager)
      • isMavenParallel

        public boolean isMavenParallel()
      • getDependenciesToScan

        public java.lang.String[] getDependenciesToScan()
      • setDependenciesToScan

        public void setDependenciesToScan​(java.lang.String[] dependenciesToScan)
      • getPluginDescriptor

        public org.apache.maven.plugin.descriptor.PluginDescriptor getPluginDescriptor()
      • getProject

        public org.apache.maven.project.MavenProject getProject()
      • setProject

        public void setProject​(org.apache.maven.project.MavenProject project)
      • getForkCount

        public java.lang.String getForkCount()
      • isReuseForks

        public boolean isReuseForks()
      • getAdditionalClasspathElements

        public java.lang.String[] getAdditionalClasspathElements()
      • setAdditionalClasspathElements

        public void setAdditionalClasspathElements​(java.lang.String[] additionalClasspathElements)
      • getClasspathDependencyExcludes

        public java.lang.String[] getClasspathDependencyExcludes()
      • setClasspathDependencyExcludes

        public void setClasspathDependencyExcludes​(java.lang.String[] classpathDependencyExcludes)
      • getClasspathDependencyScopeExclude

        public java.lang.String getClasspathDependencyScopeExclude()
      • setClasspathDependencyScopeExclude

        public void setClasspathDependencyScopeExclude​(java.lang.String classpathDependencyScopeExclude)
      • getProjectBuildDirectory

        public java.io.File getProjectBuildDirectory()
      • setProjectBuildDirectory

        public void setProjectBuildDirectory​(java.io.File projectBuildDirectory)
      • logDebugOrCliShowErrors

        protected void logDebugOrCliShowErrors​(java.lang.String s)
      • getJdkToolchain

        public java.util.Map<java.lang.String,​java.lang.String> getJdkToolchain()
      • setJdkToolchain

        public void setJdkToolchain​(java.util.Map<java.lang.String,​java.lang.String> jdkToolchain)
      • getTempDir

        public java.lang.String getTempDir()
      • setTempDir

        public void setTempDir​(java.lang.String tempDir)