Package org.apache.maven.plugin.surefire
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 Summary
FieldsModifier and TypeFieldDescriptionprotected File
The base directory of the project being tested.protected boolean
Set this to "true" to bypass unit tests entirely.protected boolean
Deprecated.Use skipTests instead.protected boolean
Set this to "true" to skip running tests, but still compile them.protected File
The directory containing generated test classes of the project being tested.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
cleanupForkConfiguration
(ForkConfiguration forkConfiguration) protected int
convertWithCoreCount
(String count) static SurefireProperties
createCopyAndReplaceForkNumPlaceholder
(SurefireProperties effectiveSystemProperties, int threadNumber) protected List<ProviderInfo>
createProviders
(org.apache.maven.plugin.surefire.TestClassPath testClasspath) boolean
void
execute()
String[]
protected ClassLoaderConfiguration
String[]
protected final PluginConsoleLogger
protected abstract String[]
String[]
protected int
protected abstract String
protected abstract String[]
abstract File
boolean
protected abstract ForkNodeFactory
abstract File
getJvm()
protected org.apache.maven.artifact.Artifact
This plugin MOJO artifact.boolean
org.apache.maven.plugin.descriptor.PluginDescriptor
protected abstract String
org.apache.maven.project.MavenProject
protected abstract String
protected abstract int
abstract String
abstract Long
org.apache.maven.execution.MavenSession
abstract File[]
abstract File
List of System properties, loaded from a file, to pass to the JUnit tests.int
int
int
int
org.apache.maven.toolchain.ToolchainManager
boolean
protected abstract void
handleSummary
(RunResult summary, Exception firstForkException) protected boolean
protected abstract boolean
protected boolean
protected boolean
boolean
boolean
boolean
protected boolean
boolean
boolean
boolean
boolean
protected abstract boolean
boolean
protected void
protected void
void
setAdditionalClasspathElements
(String[] additionalClasspathElements) void
setArgLine
(String argLine) void
setChildDelegation
(boolean childDelegation) void
setClasspathDependencyExcludes
(String[] classpathDependencyExcludes) void
setClasspathDependencyScopeExclude
(String classpathDependencyScopeExclude) void
setDependenciesToScan
(String[] dependenciesToScan) void
setDisableXmlReport
(boolean disableXmlReport) void
setEnableAssertions
(boolean enableAssertions) void
setEnvironmentVariables
(Map<String, String> environmentVariables) void
setExcludedGroups
(String excludedGroups) void
setFailIfNoTests
(boolean failIfNoTests) void
abstract void
setIncludes
(List<String> includes) void
setJdkToolchain
(Map<String, String> jdkToolchain) void
setJunitArtifactName
(String junitArtifactName) void
setObjectFactory
(String objectFactory) void
setParallel
(String parallel) void
setParallelOptimized
(boolean parallelOptimized) void
setPerCoreThreadCount
(boolean perCoreThreadCount) void
setPluginArtifactMap
(Map<String, org.apache.maven.artifact.Artifact> pluginArtifactMap) void
setProject
(org.apache.maven.project.MavenProject project) void
setProjectArtifactMap
(Map<String, org.apache.maven.artifact.Artifact> projectArtifactMap) void
setProjectBuildDirectory
(File projectBuildDirectory) void
setProperties
(Properties properties) void
setRedirectTestOutputToFile
(boolean redirectTestOutputToFile) void
setReportNameSuffix
(String reportNameSuffix) abstract void
setRunOrder
(String runOrder) abstract void
setRunOrderRandomSeed
(Long runOrderRandomSeed) void
setSession
(org.apache.maven.execution.MavenSession session) abstract void
setSuiteXmlFiles
(File[] suiteXmlFiles) void
setSystemProperties
(Properties systemProperties) abstract void
setSystemPropertiesFile
(File systemPropertiesFile) void
setSystemPropertyVariables
(Map<String, String> systemPropertyVariables) void
setTempDir
(String tempDir) void
setTestNGArtifactName
(String testNGArtifactName) void
setTestSourceDirectory
(File testSourceDirectory) void
setThreadCount
(int threadCount) void
setThreadCountClasses
(int threadCountClasses) void
setThreadCountMethods
(int threadCountMethods) void
setThreadCountSuites
(int threadCountSuites) void
setToolchainManager
(org.apache.maven.toolchain.ToolchainManager toolchainManager) void
setTrimStackTrace
(boolean trimStackTrace) protected abstract void
setUseModulePath
(boolean useModulePath) void
setUseUnlimitedThreads
(boolean useUnlimitedThreads) void
setWorkingDirectory
(File workingDirectory) CallsgetSuiteXmlFiles()
aslist
.protected abstract boolean
protected void
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.maven.plugin.surefire.SurefireExecutionParameters
getBasedir, getDebugForkedProcess, getEncoding, getExcludeJUnit5Engines, getExcludes, getFailIfNoSpecifiedTests, getForkedProcessExitTimeoutInSeconds, getForkedProcessTimeoutInSeconds, getIncludeJUnit5Engines, getMainBuildPath, getParallelTestsTimeoutForcedInSeconds, getParallelTestsTimeoutInSeconds, getReportFormat, getReportsDirectory, getShutdown, getSkipAfterFailureCount, getTest, getTestClassesDirectory, isPrintSummary, isSkip, isSkipExec, isSkipTests, isUseFile, isUseManifestOnlyJar, isUseSystemClassLoader, setBasedir, setDebugForkedProcess, setEncoding, setExcludeJUnit5Engines, setExcludes, setFailIfNoSpecifiedTests, setForkedProcessExitTimeoutInSeconds, setForkedProcessTimeoutInSeconds, setIncludeJUnit5Engines, setMainBuildPath, setParallelTestsTimeoutForcedInSeconds, setParallelTestsTimeoutInSeconds, setPrintSummary, setReportFormat, setReportsDirectory, setSkip, setSkipExec, setSkipTests, setTest, setTestClassesDirectory, setUseFile, setUseManifestOnlyJar, setUseSystemClassLoader
-
Field Details
-
skipTests
@Parameter(property="skipTests", defaultValue="false") protected boolean skipTestsSet 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 parameterskipTests
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.Use skipTests instead.This old parameter is just likeskipTests
, but bound to the old property "maven.test.skip.exec".- Since:
- 2.3
-
skip
@Parameter(property="maven.test.skip", defaultValue="false") protected boolean skipSet 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 theskipTests
parameter instead. -
basedir
The base directory of the project being tested. This can be obtained in your integration test via System.getProperty("basedir"). -
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
-
getRerunFailingTestsCount
protected abstract int getRerunFailingTestsCount() -
getIncludes
- Specified by:
getIncludes
in interfaceSurefireExecutionParameters
-
getIncludesFile
-
setIncludes
- Specified by:
setIncludes
in interfaceSurefireExecutionParameters
-
getExcludesFile
-
suiteXmlFiles
- Returns:
- list of TestNG suite XML files provided by MOJO
-
hasSuiteXmlFiles
protected abstract boolean hasSuiteXmlFiles()- Returns:
true
ifsuite-xml files array
is not empty.
-
getExcludedEnvironmentVariables
-
getSuiteXmlFiles
-
setSuiteXmlFiles
-
getRunOrder
-
setRunOrder
-
getRunOrderRandomSeed
-
setRunOrderRandomSeed
-
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
-
getReportSchemaLocation
-
useModulePath
protected abstract boolean useModulePath() -
setUseModulePath
protected abstract void setUseModulePath(boolean useModulePath) -
getEnableProcessChecker
-
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 interfaceorg.apache.maven.plugin.Mojo
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
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
-
logReportsDirectory
protected void logReportsDirectory() -
isAnyConcurrencySelected
protected boolean isAnyConcurrencySelected() -
isAnyGroupsSelected
protected boolean isAnyGroupsSelected() -
isForking
protected boolean isForking() -
getSpecificTests
- Throws:
org.apache.maven.plugin.MojoFailureException
-
getEffectiveForkCount
protected int getEffectiveForkCount() -
convertWithCoreCount
-
addPluginSpecificChecksumItems
-
hasExecutedBefore
protected boolean hasExecutedBefore() -
getClassLoaderConfiguration
-
warnIfIllegalFailOnFlakeCount
protected void warnIfIllegalFailOnFlakeCount() throws org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoFailureException
-
getLocalRepositoryPath
- Specified by:
getLocalRepositoryPath
in interfaceSurefireExecutionParameters
-
getSystemProperties
-
setSystemProperties
-
getSystemPropertyVariables
-
setSystemPropertyVariables
-
getSystemPropertiesFile
List of System properties, loaded from a file, to pass to the JUnit tests.- Since:
- 2.8.2
-
setSystemPropertiesFile
-
setProperties
-
getPluginArtifactMap
-
setPluginArtifactMap
-
getProjectArtifactMap
-
setProjectArtifactMap
-
getReportNameSuffix
-
setReportNameSuffix
-
isRedirectTestOutputToFile
public boolean isRedirectTestOutputToFile() -
setRedirectTestOutputToFile
public void setRedirectTestOutputToFile(boolean redirectTestOutputToFile) -
getFailIfNoTests
public boolean getFailIfNoTests() -
setFailIfNoTests
public void setFailIfNoTests(boolean failIfNoTests) -
getJvm
-
getArgLine
-
setArgLine
-
getEnvironmentVariables
-
setEnvironmentVariables
-
getWorkingDirectory
-
setWorkingDirectory
-
isChildDelegation
public boolean isChildDelegation() -
setChildDelegation
public void setChildDelegation(boolean childDelegation) -
getGroups
-
setGroups
-
getExcludedGroups
-
setExcludedGroups
-
getJunitArtifactName
-
setJunitArtifactName
-
getTestNGArtifactName
-
setTestNGArtifactName
-
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
-
setParallel
-
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
-
setObjectFactory
-
getToolchainManager
public org.apache.maven.toolchain.ToolchainManager getToolchainManager() -
setToolchainManager
public void setToolchainManager(org.apache.maven.toolchain.ToolchainManager toolchainManager) -
isMavenParallel
public boolean isMavenParallel() -
getDependenciesToScan
-
setDependenciesToScan
-
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
- Specified by:
getTestSourceDirectory
in interfaceSurefireExecutionParameters
-
setTestSourceDirectory
- Specified by:
setTestSourceDirectory
in interfaceSurefireExecutionParameters
-
getForkCount
-
isReuseForks
public boolean isReuseForks() -
getAdditionalClasspathElements
-
setAdditionalClasspathElements
-
getClasspathDependencyExcludes
-
setClasspathDependencyExcludes
-
getClasspathDependencyScopeExclude
-
setClasspathDependencyScopeExclude
-
getProjectBuildDirectory
-
setProjectBuildDirectory
-
logDebugOrCliShowErrors
-
getJdkToolchain
-
setJdkToolchain
-
getTempDir
-
setTempDir
-