Class AbstractSurefireMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugin.surefire.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 Details

    • 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 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 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 Details

    • AbstractSurefireMojo

      public AbstractSurefireMojo()
  • Method Details

    • getPluginName

      protected abstract String getPluginName()
    • getRerunFailingTestsCount

      protected abstract int getRerunFailingTestsCount()
    • getIncludes

      public abstract List<String> getIncludes()
      Specified by:
      getIncludes in interface SurefireExecutionParameters
    • getIncludesFile

      public abstract File getIncludesFile()
    • setIncludes

      public abstract void setIncludes(List<String> includes)
      Specified by:
      setIncludes in interface SurefireExecutionParameters
    • getExcludesFile

      public abstract File getExcludesFile()
    • suiteXmlFiles

      protected abstract List<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 String[] getExcludedEnvironmentVariables()
    • getSuiteXmlFiles

      public abstract File[] getSuiteXmlFiles()
    • setSuiteXmlFiles

      public abstract void setSuiteXmlFiles(File[] suiteXmlFiles)
    • getRunOrder

      public abstract String getRunOrder()
    • setRunOrder

      public abstract void setRunOrder(String runOrder)
    • getRunOrderRandomSeed

      public abstract Long getRunOrderRandomSeed()
    • setRunOrderRandomSeed

      public abstract void setRunOrderRandomSeed(Long runOrderRandomSeed)
    • handleSummary

      protected abstract void handleSummary(RunResult summary, 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 String[] getDefaultIncludes()
    • getReportSchemaLocation

      protected abstract String getReportSchemaLocation()
    • useModulePath

      protected abstract boolean useModulePath()
    • setUseModulePath

      protected abstract void setUseModulePath(boolean useModulePath)
    • getEnableProcessChecker

      protected abstract String getEnableProcessChecker()
    • getForkNode

      protected abstract 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
    • getConsoleLogger

      @Nonnull protected final PluginConsoleLogger getConsoleLogger()
    • createProviders

      protected 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 TestListResolver getSpecificTests() throws org.apache.maven.plugin.MojoFailureException
      Throws:
      org.apache.maven.plugin.MojoFailureException
    • getEffectiveForkCount

      protected int getEffectiveForkCount()
    • convertWithCoreCount

      protected int convertWithCoreCount(String count)
    • addPluginSpecificChecksumItems

      protected void addPluginSpecificChecksumItems(ChecksumCalculator checksum)
    • hasExecutedBefore

      protected boolean hasExecutedBefore()
    • getClassLoaderConfiguration

      @Nonnull protected ClassLoaderConfiguration getClassLoaderConfiguration()
    • warnIfIllegalFailOnFlakeCount

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

      public String getLocalRepositoryPath()
      Specified by:
      getLocalRepositoryPath in interface SurefireExecutionParameters
    • getSystemProperties

      public Properties getSystemProperties()
    • setSystemProperties

      public void setSystemProperties(Properties systemProperties)
    • getSystemPropertyVariables

      public Map<String,String> getSystemPropertyVariables()
    • setSystemPropertyVariables

      public void setSystemPropertyVariables(Map<String,String> systemPropertyVariables)
    • getSystemPropertiesFile

      public abstract 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(File systemPropertiesFile)
    • setProperties

      public void setProperties(Properties properties)
    • getPluginArtifactMap

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

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

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

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

      public String getReportNameSuffix()
    • setReportNameSuffix

      public void setReportNameSuffix(String reportNameSuffix)
    • isRedirectTestOutputToFile

      public boolean isRedirectTestOutputToFile()
    • setRedirectTestOutputToFile

      public void setRedirectTestOutputToFile(boolean redirectTestOutputToFile)
    • getFailIfNoTests

      public boolean getFailIfNoTests()
    • setFailIfNoTests

      public void setFailIfNoTests(boolean failIfNoTests)
    • getJvm

      public String getJvm()
    • getArgLine

      public String getArgLine()
    • setArgLine

      public void setArgLine(String argLine)
    • getEnvironmentVariables

      public Map<String,String> getEnvironmentVariables()
    • setEnvironmentVariables

      public void setEnvironmentVariables(Map<String,String> environmentVariables)
    • getWorkingDirectory

      public File getWorkingDirectory()
    • setWorkingDirectory

      public void setWorkingDirectory(File workingDirectory)
    • isChildDelegation

      public boolean isChildDelegation()
    • setChildDelegation

      public void setChildDelegation(boolean childDelegation)
    • getGroups

      public String getGroups()
    • setGroups

      public void setGroups(String groups)
    • getExcludedGroups

      public String getExcludedGroups()
    • setExcludedGroups

      public void setExcludedGroups(String excludedGroups)
    • getJunitArtifactName

      public String getJunitArtifactName()
    • setJunitArtifactName

      public void setJunitArtifactName(String junitArtifactName)
    • getTestNGArtifactName

      public String getTestNGArtifactName()
    • setTestNGArtifactName

      public void setTestNGArtifactName(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 String getParallel()
    • setParallel

      public void setParallel(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 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 String getObjectFactory()
    • setObjectFactory

      public void setObjectFactory(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 String[] getDependenciesToScan()
    • setDependenciesToScan

      public void setDependenciesToScan(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)
    • getTestSourceDirectory

      public File getTestSourceDirectory()
      Specified by:
      getTestSourceDirectory in interface SurefireExecutionParameters
    • setTestSourceDirectory

      public void setTestSourceDirectory(File testSourceDirectory)
      Specified by:
      setTestSourceDirectory in interface SurefireExecutionParameters
    • getForkCount

      public String getForkCount()
    • isReuseForks

      public boolean isReuseForks()
    • getAdditionalClasspathElements

      public String[] getAdditionalClasspathElements()
    • setAdditionalClasspathElements

      public void setAdditionalClasspathElements(String[] additionalClasspathElements)
    • getClasspathDependencyExcludes

      public String[] getClasspathDependencyExcludes()
    • setClasspathDependencyExcludes

      public void setClasspathDependencyExcludes(String[] classpathDependencyExcludes)
    • getClasspathDependencyScopeExclude

      public String getClasspathDependencyScopeExclude()
    • setClasspathDependencyScopeExclude

      public void setClasspathDependencyScopeExclude(String classpathDependencyScopeExclude)
    • getProjectBuildDirectory

      public File getProjectBuildDirectory()
    • setProjectBuildDirectory

      public void setProjectBuildDirectory(File projectBuildDirectory)
    • logDebugOrCliShowErrors

      protected void logDebugOrCliShowErrors(String s)
    • getJdkToolchain

      public Map<String,String> getJdkToolchain()
    • setJdkToolchain

      public void setJdkToolchain(Map<String,String> jdkToolchain)
    • getTempDir

      public String getTempDir()
    • setTempDir

      public void setTempDir(String tempDir)