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.
- Author:
- Stephen Connolly
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FileThe base directory of the project being tested.protected booleanSet this to "true" to bypass unit tests entirely.protected booleanDeprecated.Use skipTests instead.protected booleanSet this to "true" to skip running tests, but still compile them.protected FileThe 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 voidprotected voidcleanupForkConfiguration(ForkConfiguration forkConfiguration) protected intconvertWithCoreCount(String count) static SurefirePropertiescreateCopyAndReplaceForkNumPlaceholder(SurefireProperties effectiveSystemProperties, int threadNumber) protected List<ProviderInfo> createProviders(org.apache.maven.plugin.surefire.TestClassPath testClasspath) booleanvoidexecute()String[]protected ClassLoaderConfigurationString[]protected final PluginConsoleLoggerprotected abstract String[]String[]protected intprotected abstract Stringprotected abstract String[]abstract Filebooleanprotected abstract ForkNodeFactoryabstract FilegetJvm()protected org.apache.maven.artifact.ArtifactThis plugin MOJO artifact.booleanorg.apache.maven.plugin.descriptor.PluginDescriptorprotected abstract Stringorg.apache.maven.project.MavenProjectprotected abstract Stringprotected abstract intabstract Stringabstract Longorg.apache.maven.execution.MavenSessionabstract File[]abstract FileList of System properties, loaded from a file, to pass to the JUnit tests.intintintintorg.apache.maven.toolchain.ToolchainManagerbooleanprotected abstract voidhandleSummary(RunResult summary, Exception firstForkException) protected booleanprotected abstract booleanprotected booleanprotected booleanbooleanbooleanbooleanbooleanprotected booleanbooleanbooleanbooleanbooleanprotected abstract booleanbooleanprotected voidprotected voidprotected Collection<org.apache.maven.artifact.Artifact> resolveDependencies(List<org.apache.maven.model.Dependency> dependencies) voidsetAdditionalClasspathElements(String[] additionalClasspathElements) voidsetArgLine(String argLine) voidsetChildDelegation(boolean childDelegation) voidsetClasspathDependencyExcludes(String[] classpathDependencyExcludes) voidsetClasspathDependencyScopeExclude(String classpathDependencyScopeExclude) voidsetDependenciesToScan(String[] dependenciesToScan) voidsetEnableAssertions(boolean enableAssertions) voidsetEnableOutErrElements(boolean enableOutErrElements) voidsetEnablePropertiesElement(boolean enablePropertiesElement) voidsetEnvironmentVariables(Map<String, String> environmentVariables) voidsetExcludedGroups(String excludedGroups) voidsetFailIfNoTests(boolean failIfNoTests) voidabstract voidsetIncludes(List<String> includes) voidsetJdkToolchain(Map<String, String> jdkToolchain) voidsetJunitArtifactName(String junitArtifactName) voidsetObjectFactory(String objectFactory) voidsetParallel(String parallel) voidsetParallelOptimized(boolean parallelOptimized) voidsetPerCoreThreadCount(boolean perCoreThreadCount) voidsetPluginArtifactMap(Map<String, org.apache.maven.artifact.Artifact> pluginArtifactMap) voidsetProject(org.apache.maven.project.MavenProject project) voidsetProjectArtifactMap(Map<String, org.apache.maven.artifact.Artifact> projectArtifactMap) voidsetProjectBuildDirectory(File projectBuildDirectory) voidsetProperties(Properties properties) voidsetRedirectTestOutputToFile(boolean redirectTestOutputToFile) voidsetReportNameSuffix(String reportNameSuffix) abstract voidsetRunOrder(String runOrder) abstract voidsetRunOrderRandomSeed(Long runOrderRandomSeed) voidsetSession(org.apache.maven.execution.MavenSession session) abstract voidsetSuiteXmlFiles(File[] suiteXmlFiles) voidsetSystemProperties(Properties systemProperties) abstract voidsetSystemPropertiesFile(File systemPropertiesFile) voidsetSystemPropertyVariables(Map<String, String> systemPropertyVariables) voidsetTempDir(String tempDir) voidsetTestNGArtifactName(String testNGArtifactName) voidsetTestSourceDirectory(File testSourceDirectory) voidsetThreadCount(int threadCount) voidsetThreadCountClasses(int threadCountClasses) voidsetThreadCountMethods(int threadCountMethods) voidsetThreadCountSuites(int threadCountSuites) voidsetToolchainManager(org.apache.maven.toolchain.ToolchainManager toolchainManager) voidsetTrimStackTrace(boolean trimStackTrace) protected abstract voidsetUseModulePath(boolean useModulePath) voidsetUseUnlimitedThreads(boolean useUnlimitedThreads) voidsetWorkingDirectory(File workingDirectory) CallsgetSuiteXmlFiles()aslist.protected abstract booleanprotected voidMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 parameterskipTestsand 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 theskipTestsparameter 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:
getIncludesin interfaceSurefireExecutionParameters
-
getIncludesFile
-
setIncludes
- Specified by:
setIncludesin interfaceSurefireExecutionParameters
-
getExcludesFile
-
suiteXmlFiles
- Returns:
- list of TestNG suite XML files provided by MOJO
-
hasSuiteXmlFiles
protected abstract boolean hasSuiteXmlFiles()- Returns:
trueifsuite-xml files arrayis 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.MojoExecutionExceptionorg.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:
executein interfaceorg.apache.maven.plugin.Mojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.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
-
resolveDependencies
protected Collection<org.apache.maven.artifact.Artifact> resolveDependencies(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
-
getLocalRepositoryPath
- Specified by:
getLocalRepositoryPathin 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) -
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
-
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:
getTestSourceDirectoryin interfaceSurefireExecutionParameters
-
setTestSourceDirectory
- Specified by:
setTestSourceDirectoryin interfaceSurefireExecutionParameters
-
getForkCount
-
isReuseForks
public boolean isReuseForks() -
getAdditionalClasspathElements
-
setAdditionalClasspathElements
-
getClasspathDependencyExcludes
-
setClasspathDependencyExcludes
-
getClasspathDependencyScopeExclude
-
setClasspathDependencyScopeExclude
-
getProjectBuildDirectory
-
setProjectBuildDirectory
-
logDebugOrCliShowErrors
-
getJdkToolchain
-
setJdkToolchain
-
getTempDir
-
setTempDir
-