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.
    Version:
    $Id: SurefirePlugin.java 945065 2010-05-17 10:26:22Z stephenc $
    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.
        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}")
        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. *
      • THREAD_NUMBER_PLACEHOLDER

        public static final java.lang.String THREAD_NUMBER_PLACEHOLDER
        The placeholder that is replaced by the executing thread's running number. The thread number range starts with 1 Deprecated.
        See Also:
        Constant Field Values
      • FORK_NUMBER_PLACEHOLDER

        public static final java.lang.String FORK_NUMBER_PLACEHOLDER
        The placeholder that is replaced by the executing fork's running number. The fork number range starts with 1
        See Also:
        Constant Field Values
    • 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.
      • 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)
      • handleSummary

        protected abstract void handleSummary​(org.apache.maven.surefire.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()
      • getMojoArtifact

        protected abstract org.apache.maven.artifact.Artifact getMojoArtifact()
      • 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()
                                                        throws org.apache.maven.plugin.MojoFailureException,
                                                               org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoFailureException
        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()
      • getStatisticsFile

        public java.io.File getStatisticsFile​(java.lang.String configurationHash)
      • getSpecificTests

        public org.apache.maven.surefire.testset.TestListResolver getSpecificTests()
      • 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()
      • 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 java.io.File getSystemPropertiesFile()
      • setSystemPropertiesFile

        public 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 java.lang.Boolean getFailIfNoTests()
      • setFailIfNoTests

        public void setFailIfNoTests​(boolean failIfNoTests)
      • getForkMode

        public java.lang.String getForkMode()
      • setForkMode

        public void setForkMode​(java.lang.String forkMode)
      • 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)
      • getJunitPlatformArtifactName

        public java.lang.String getJunitPlatformArtifactName()
      • setJunitPlatformArtifactName

        public void setJunitPlatformArtifactName​(java.lang.String junitPlatformArtifactName)
      • 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)
      • getArtifactResolver

        public org.apache.maven.artifact.resolver.ArtifactResolver getArtifactResolver()
      • setArtifactResolver

        public void setArtifactResolver​(org.apache.maven.artifact.resolver.ArtifactResolver artifactResolver)
      • getArtifactFactory

        public org.apache.maven.artifact.factory.ArtifactFactory getArtifactFactory()
      • setArtifactFactory

        public void setArtifactFactory​(org.apache.maven.artifact.factory.ArtifactFactory artifactFactory)
      • getRemoteRepositories

        public java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> getRemoteRepositories()
      • setRemoteRepositories

        public void setRemoteRepositories​(java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteRepositories)
      • getMetadataSource

        public org.apache.maven.artifact.metadata.ArtifactMetadataSource getMetadataSource()
      • setMetadataSource

        public void setMetadataSource​(org.apache.maven.artifact.metadata.ArtifactMetadataSource metadataSource)
      • isDisableXmlReport

        public boolean isDisableXmlReport()
      • setDisableXmlReport

        public void setDisableXmlReport​(boolean disableXmlReport)
      • isEnableAssertions

        public boolean isEnableAssertions()
      • effectiveIsEnableAssertions

        public boolean effectiveIsEnableAssertions()
      • setEnableAssertions

        public void setEnableAssertions​(boolean enableAssertions)
      • 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)
      • getTempDir

        public java.lang.String getTempDir()
      • setTempDir

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