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 FileThe base directory of the project being tested.static final StringThe placeholder that is replaced by the executing fork's running number.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.static final StringThe placeholder that is replaced by the executing thread's running number.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>booleanvoidexecute()String[]org.apache.maven.artifact.factory.ArtifactFactoryorg.apache.maven.artifact.resolver.ArtifactResolverprotected org.apache.maven.surefire.booter.ClassLoaderConfigurationString[]protected final PluginConsoleLoggerprotected abstract String[]String[]protected intabstract Fileabstract FilegetJvm()org.apache.maven.artifact.repository.ArtifactRepositoryorg.apache.maven.artifact.metadata.ArtifactMetadataSourceprotected abstract org.apache.maven.artifact.Artifactbooleanorg.apache.maven.plugin.descriptor.PluginDescriptorprotected abstract Stringorg.apache.maven.project.MavenProjectList<org.apache.maven.artifact.repository.ArtifactRepository>protected abstract Stringprotected abstract intabstract Stringorg.apache.maven.execution.MavenSessionorg.apache.maven.surefire.testset.TestListResolvergetStatisticsFile(String configurationHash) abstract File[]intintintintorg.apache.maven.toolchain.ToolchainManagerbooleanprotected abstract voidhandleSummary(org.apache.maven.surefire.suite.RunResult summary, Exception firstForkException) protected booleanprotected abstract booleanprotected booleanprotected booleanbooleanbooleanbooleanprotected booleanbooleanbooleanbooleanbooleanprotected abstract booleanbooleanprotected voidprotected voidvoidsetAdditionalClasspathElements(String[] additionalClasspathElements) voidsetArgLine(String argLine) voidsetArtifactFactory(org.apache.maven.artifact.factory.ArtifactFactory artifactFactory) voidsetArtifactResolver(org.apache.maven.artifact.resolver.ArtifactResolver artifactResolver) voidsetChildDelegation(boolean childDelegation) voidsetClasspathDependencyExcludes(String[] classpathDependencyExcludes) voidsetClasspathDependencyScopeExclude(String classpathDependencyScopeExclude) voidsetDependenciesToScan(String[] dependenciesToScan) voidsetDisableXmlReport(boolean disableXmlReport) voidsetEnableAssertions(boolean enableAssertions) voidsetEnvironmentVariables(Map<String, String> environmentVariables) voidsetExcludedGroups(String excludedGroups) voidsetExcludes(List<String> excludes) voidsetFailIfNoTests(boolean failIfNoTests) voidsetForkMode(String forkMode) voidabstract voidsetIncludes(List<String> includes) voidsetJunitArtifactName(String junitArtifactName) voidsetJunitPlatformArtifactName(String junitPlatformArtifactName) voidsetLocalRepository(org.apache.maven.artifact.repository.ArtifactRepository localRepository) voidsetMetadataSource(org.apache.maven.artifact.metadata.ArtifactMetadataSource metadataSource) 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) voidsetRemoteRepositories(List<org.apache.maven.artifact.repository.ArtifactRepository> remoteRepositories) voidsetReportNameSuffix(String reportNameSuffix) abstract voidsetRunOrder(String runOrder) voidsetSession(org.apache.maven.execution.MavenSession session) abstract voidsetSuiteXmlFiles(File[] suiteXmlFiles) voidsetSystemProperties(Properties systemProperties) 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) voidsetUseUnlimitedThreads(boolean useUnlimitedThreads) voidsetWorkingDirectory(File workingDirectory) CallsgetSuiteXmlFiles()aslist.Methods 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, getClassesDirectory, getDebugForkedProcess, getEncoding, getFailIfNoSpecifiedTests, getForkedProcessExitTimeoutInSeconds, getForkedProcessTimeoutInSeconds, getParallelTestsTimeoutForcedInSeconds, getParallelTestsTimeoutInSeconds, getReportFormat, getReportsDirectory, getShutdown, getSkipAfterFailureCount, getTest, getTestClassesDirectory, isPrintSummary, isSkip, isSkipExec, isSkipTests, isUseFile, isUseManifestOnlyJar, isUseSystemClassLoader, setBasedir, setClassesDirectory, setDebugForkedProcess, setEncoding, setFailIfNoSpecifiedTests, setForkedProcessExitTimeoutInSeconds, setForkedProcessTimeoutInSeconds, 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.- 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. * -
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:
-
FORK_NUMBER_PLACEHOLDER
The placeholder that is replaced by the executing fork's running number. The fork number range starts with 1- See Also:
-
-
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
CallsgetSuiteXmlFiles()aslist. Never returns null.- Returns:
- list of TestNG suite XML files provided by MOJO
-
hasSuiteXmlFiles
protected abstract boolean hasSuiteXmlFiles()- Returns:
trueifsuite-xml files arrayis not empty.
-
getSuiteXmlFiles
-
setSuiteXmlFiles
-
getRunOrder
-
setRunOrder
-
handleSummary
protected abstract void handleSummary(org.apache.maven.surefire.suite.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
-
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:
executein interfaceorg.apache.maven.plugin.Mojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
getConsoleLogger
-
createProviders
protected List<ProviderInfo> createProviders() throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoFailureExceptionorg.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() -
getStatisticsFile
-
getSpecificTests
public org.apache.maven.surefire.testset.TestListResolver getSpecificTests() -
getEffectiveForkCount
protected int getEffectiveForkCount() -
convertWithCoreCount
-
addPluginSpecificChecksumItems
-
hasExecutedBefore
protected boolean hasExecutedBefore() -
getClassLoaderConfiguration
@Nonnull protected org.apache.maven.surefire.booter.ClassLoaderConfiguration getClassLoaderConfiguration() -
getExcludes
- Specified by:
getExcludesin interfaceSurefireExecutionParameters
-
setExcludes
- Specified by:
setExcludesin interfaceSurefireExecutionParameters
-
getLocalRepository
public org.apache.maven.artifact.repository.ArtifactRepository getLocalRepository()- Specified by:
getLocalRepositoryin interfaceSurefireExecutionParameters
-
setLocalRepository
public void setLocalRepository(org.apache.maven.artifact.repository.ArtifactRepository localRepository) - Specified by:
setLocalRepositoryin interfaceSurefireExecutionParameters
-
getSystemProperties
-
setSystemProperties
-
getSystemPropertyVariables
-
setSystemPropertyVariables
-
getSystemPropertiesFile
-
setSystemPropertiesFile
-
setProperties
-
getPluginArtifactMap
-
setPluginArtifactMap
-
getProjectArtifactMap
-
setProjectArtifactMap
-
getReportNameSuffix
-
setReportNameSuffix
-
isRedirectTestOutputToFile
public boolean isRedirectTestOutputToFile() -
setRedirectTestOutputToFile
public void setRedirectTestOutputToFile(boolean redirectTestOutputToFile) -
getFailIfNoTests
-
setFailIfNoTests
public void setFailIfNoTests(boolean failIfNoTests) -
getForkMode
-
setForkMode
-
getJvm
-
getArgLine
-
setArgLine
-
getEnvironmentVariables
-
setEnvironmentVariables
-
getWorkingDirectory
-
setWorkingDirectory
-
isChildDelegation
public boolean isChildDelegation() -
setChildDelegation
public void setChildDelegation(boolean childDelegation) -
getGroups
-
setGroups
-
getExcludedGroups
-
setExcludedGroups
-
getJunitArtifactName
-
setJunitArtifactName
-
getJunitPlatformArtifactName
-
setJunitPlatformArtifactName
-
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) -
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
-
setRemoteRepositories
public void setRemoteRepositories(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
-
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
-
getTempDir
-
setTempDir
-