public abstract class AbstractSurefireMojo extends AbstractMojo implements SurefireExecutionParameters
Modifier and Type | Class and Description |
---|---|
class |
AbstractSurefireMojo.DynamicProviderInfo
Provides the Provider information for manually configured providers
|
Modifier and Type | Field and Description |
---|---|
protected String |
argLine
Arbitrary JVM options to set on the command line.
|
protected ArtifactFactory |
artifactFactory
Creates the artifact.
|
protected ArtifactResolver |
artifactResolver
Resolves the artifacts needed.
|
protected File |
basedir
The base directory of the project being tested.
|
protected boolean |
childDelegation
When false it makes tests run using the standard classloader delegation instead of the default Maven isolated
classloader.
|
protected File |
classesDirectory
The directory containing generated classes of the project being tested.
|
protected boolean |
disableXmlReport
Flag to disable the generation of report files in xml format.
|
protected boolean |
enableAssertions
By default, Surefire enables JVM assertions for the execution of your test cases.
|
protected Map<String,String> |
environmentVariables
Additional environment variables to set on the command line.
|
protected String |
excludedGroups
(TestNG/JUnit47 provider with JUnit4.8+ only) Excluded groups.
|
protected List<String> |
excludes
A list of <exclude> elements specifying the tests (by pattern) that should be excluded in testing.
|
protected File |
excludesFile
A file containing exclude patterns.
|
protected Boolean |
failIfNoTests
Set this to "true" to cause a failure if there are no tests to run.
|
static String |
FORK_NUMBER_PLACEHOLDER
The placeholder that is replaced by the executing fork's running number.
|
protected String |
forkMode
DEPRECATED since version 2.14.
|
protected String |
groups
(TestNG/JUnit47 provider with JUnit4.8+ only) Groups for this test.
|
protected File |
includesFile
A file containing include patterns.
|
protected String |
junitArtifactName
Allows you to specify the name of the JUnit artifact.
|
protected String |
jvm
Option to specify the jvm (or path to the java executable) to use with the forking options.
|
protected ArtifactRepository |
localRepository
ArtifactRepository of the localRepository.
|
protected ArtifactMetadataSource |
metadataSource
For retrieval of artifact's metadata.
|
protected String |
objectFactory
(TestNG only) Define the factory class used to create all test instances.
|
protected String |
parallel
(TestNG provider) When you use the
parallel attribute, TestNG will try to run all your test methods
in separate threads, except for methods that depend on each other, which will be run in the same thread in order
to respect their order of execution. |
protected Boolean |
parallelMavenExecution |
protected boolean |
parallelOptimized
(JUnit 4.7 / provider only) The thread counts do not exceed the number of parallel suite, class runners and
average number of methods per class if set to true.
|
protected boolean |
perCoreThreadCount
(JUnit 4.7 provider) Indicates that threadCount, threadCountSuites, threadCountClasses, threadCountMethods
are per cpu core.
|
protected Map<String,Artifact> |
pluginArtifactMap
Map of plugin artifacts.
|
protected PluginDescriptor |
pluginDescriptor
Information about this plugin, mainly used to lookup this plugin's configuration from the currently executing
project.
|
protected MavenProject |
project
The Maven Project Object.
|
protected Map<String,Artifact> |
projectArtifactMap
Map of project artifacts.
|
protected Properties |
properties
List of properties for configuring all TestNG related configurations.
|
protected boolean |
redirectTestOutputToFile
Set this to "true" to redirect the unit test standard output to a file (found in
reportsDirectory/testName-output.txt).
|
protected List<ArtifactRepository> |
remoteRepositories
The remote plugin repositories declared in the POM.
|
protected String |
reportNameSuffix
Add custom text into report filename: TEST-testClassName-reportNameSuffix.xml,
testClassName-reportNameSuffix.txt and testClassName-reportNameSuffix-output.txt.
|
protected MavenSession |
session
The current build session instance.
|
protected boolean |
skip
Set this to "true" to bypass unit tests entirely.
|
protected boolean |
skipExec
Deprecated.
Use skipTests instead.
|
protected boolean |
skipTests
Set this to "true" to skip running tests, but still compile them.
|
protected Properties |
systemProperties
Deprecated.
Use systemPropertyVariables instead.
|
protected File |
systemPropertiesFile
List of System properties, loaded from a file, to pass to the JUnit tests.
|
protected Map<String,String> |
systemPropertyVariables
List of System properties to pass to the JUnit tests.
|
protected File |
testClassesDirectory
The directory containing generated test classes of the project being tested.
|
protected String |
testNGArtifactName
Allows you to specify the name of the TestNG artifact.
|
protected File |
testSourceDirectory
The test source directory containing test class sources.
|
static String |
THREAD_NUMBER_PLACEHOLDER
The placeholder that is replaced by the executing thread's running number.
|
protected int |
threadCount
(TestNG/JUnit 4.7 provider) The attribute thread-count allows you to specify how many threads should be
allocated for this execution.
|
protected int |
threadCountClasses
(JUnit 4.7 provider) This attribute allows you to specify the concurrency in test classes, i.e.:
number of concurrent classes if
threadCount is 0 or unspecified
limited classes concurrency if useUnlimitedThreads is set to true
if threadCount and certain thread-count parameters are > 0 for parallel , the
concurrency is computed from ratio. |
protected int |
threadCountMethods
(JUnit 4.7 provider) This attribute allows you to specify the concurrency in test methods, i.e.:
number of concurrent methods if
threadCount is 0 or unspecified
limited concurrency of methods if useUnlimitedThreads is set to true
if threadCount and certain thread-count parameters are > 0 for parallel , the
concurrency is computed from ratio. |
protected int |
threadCountSuites
(JUnit 4.7 provider) This attribute allows you to specify the concurrency in test suites, i.e.:
number of concurrent suites if
threadCount is 0 or unspecified
limited suites concurrency if useUnlimitedThreads is set to true
if threadCount and certain thread-count parameters are > 0 for parallel , the
concurrency is computed from ratio. |
protected ToolchainManager |
toolchainManager |
protected boolean |
trimStackTrace
Whether to trim the stack trace in the reports to just the lines within the test, or show the full trace.
|
protected boolean |
useUnlimitedThreads
(JUnit 4.7 provider) Indicates that the thread pool will be unlimited.
|
protected File |
workingDirectory
Command line working directory.
|
Constructor and Description |
---|
AbstractSurefireMojo() |
getLog, getPluginContext, setLog, setPluginContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBasedir, getClassesDirectory, getDebugForkedProcess, getFailIfNoSpecifiedTests, getForkedProcessTimeoutInSeconds, getParallelTestsTimeoutForcedInSeconds, getParallelTestsTimeoutInSeconds, getReportFormat, getReportsDirectory, getTest, getTestClassesDirectory, getTestMethod, isPrintSummary, isSkip, isSkipExec, isSkipTests, isUseFile, isUseManifestOnlyJar, isUseSystemClassLoader, setBasedir, setClassesDirectory, setDebugForkedProcess, setFailIfNoSpecifiedTests, setForkedProcessTimeoutInSeconds, setParallelTestsTimeoutForcedInSeconds, setParallelTestsTimeoutInSeconds, setPrintSummary, setReportFormat, setReportsDirectory, setSkip, setSkipExec, setSkipTests, setTest, setTestClassesDirectory, setUseFile, setUseManifestOnlyJar, setUseSystemClassLoader
@Parameter(defaultValue="${plugin}", readonly=true) protected PluginDescriptor pluginDescriptor
@Parameter(property="skipTests", defaultValue="false") protected boolean skipTests
@Parameter(property="maven.test.skip.exec") protected boolean skipExec
skipTests
, but bound to the old property "maven.test.skip.exec".@Parameter(property="maven.test.skip", defaultValue="false") protected boolean skip
skipTests
parameter instead.@Component protected MavenProject project
@Parameter(defaultValue="${basedir}") protected File basedir
@Parameter(defaultValue="${project.build.testOutputDirectory}") protected File testClassesDirectory
@Parameter(defaultValue="${project.build.outputDirectory}") protected File classesDirectory
@Parameter(defaultValue="${project.build.testSourceDirectory}", required=true) protected File testSourceDirectory
@Parameter protected File includesFile
includes
are
also specified these patterns are appended.@Parameter protected List<String> excludes
test
parameter is not specified, the default excludes will be
<excludes>
<exclude>**/*$*</exclude>
</excludes>
(which excludes all inner classes).suiteXmlFiles
parameter is specified.
Each exclude item may also contain a comma-separated sublist of items, which will be treated as multiple
<exclude> entries.testClassesDirectory
which defaults
to the POM property ${project.build.testOutputDirectory}
, typically src/test/java
unless overridden.@Parameter protected File excludesFile
excludes
are
also specified these patterns are appended.@Parameter(defaultValue="${localRepository}", required=true, readonly=true) protected ArtifactRepository localRepository
@Parameter protected Properties systemProperties
@Parameter protected Map<String,String> systemPropertyVariables
@Parameter protected File systemPropertiesFile
@Parameter protected Properties properties
@Parameter(property="plugin.artifactMap", required=true, readonly=true) protected Map<String,Artifact> pluginArtifactMap
@Parameter(property="project.artifactMap", readonly=true, required=true) protected Map<String,Artifact> projectArtifactMap
@Parameter(property="surefire.reportNameSuffix", defaultValue="") protected String reportNameSuffix
@Parameter(property="maven.test.redirectTestOutputToFile", defaultValue="false") protected boolean redirectTestOutputToFile
@Parameter(property="failIfNoTests") protected Boolean failIfNoTests
@Parameter(property="forkMode", defaultValue="once") protected String forkMode
forkCount
and reuseForks
instead.
threadCount
parallel forks, each executing one test-class. See also parameter
reuseForks
.@Parameter(property="jvm") protected String jvm
@Parameter(property="argLine") protected String argLine
@{...}allows late replacement of properties when the plugin is executed, so properties that have been modified by other plugins will be picked up correctly. See the Frequently Asked Questions page with more details:
@Parameter protected Map<String,String> environmentVariables
@Parameter(property="basedir") protected File workingDirectory
@Parameter(property="childDelegation", defaultValue="false") protected boolean childDelegation
@Parameter(property="groups") protected String groups
suiteXmlFiles
parameter is specified.@Parameter(property="excludedGroups") protected String excludedGroups
suiteXmlFiles
parameter is specified.@Parameter(property="junitArtifactName", defaultValue="junit:junit") protected String junitArtifactName
junit:junit
will be used.@Parameter(property="testNGArtifactName", defaultValue="org.testng:testng") protected String testNGArtifactName
org.testng:testng
will be used.@Parameter(property="threadCount") protected int threadCount
parallel
parameter.@Parameter(property="perCoreThreadCount", defaultValue="true") protected boolean perCoreThreadCount
@Parameter(property="useUnlimitedThreads", defaultValue="false") protected boolean useUnlimitedThreads
parallel
parameter and
the actual number of classes/methods will decide. Setting this to "true" effectively disables
perCoreThreadCount
and threadCount
. Defaults to "false".@Parameter(property="parallel") protected String parallel
parallel
attribute, TestNG will try to run all your test methods
in separate threads, except for methods that depend on each other, which will be run in the same thread in order
to respect their order of execution.
(JUnit 4.7 provider) Supports values "classes"/"methods"/"both" to run in separate threads, as controlled by
threadCount
.@Parameter(property="parallelOptimized", defaultValue="true") protected boolean parallelOptimized
@Parameter(property="threadCountSuites", defaultValue="0") protected int threadCountSuites
threadCount
is 0 or unspecifieduseUnlimitedThreads
is set to truethreadCount
and certain thread-count parameters are > 0 for parallel
, the
concurrency is computed from ratio. For instance parallel=all and the ratio between
threadCountSuites:threadCountClasses
:threadCountMethods
is
2:3:5, there is 20% of threadCount
in concurrent suites.parallel
parameter.
The default value 0
behaves same as unspecified one.@Parameter(property="threadCountClasses", defaultValue="0") protected int threadCountClasses
threadCount
is 0 or unspecifieduseUnlimitedThreads
is set to truethreadCount
and certain thread-count parameters are > 0 for parallel
, the
concurrency is computed from ratio. For instance parallel=all and the ratio between
threadCountSuites
:threadCountClasses:threadCountMethods
is
2:3:5, there is 30% of threadCount
in concurrent classes.parallel
parameter.
The default value 0
behaves same as unspecified one.@Parameter(property="threadCountMethods", defaultValue="0") protected int threadCountMethods
threadCount
is 0 or unspecifieduseUnlimitedThreads
is set to truethreadCount
and certain thread-count parameters are > 0 for parallel
, the
concurrency is computed from ratio. For instance parallel=all and the ratio between
threadCountSuites
:threadCountClasses
:threadCountMethods is 2:3:5,
there is 50% of threadCount
in concurrent methods.parallel
parameter. The default value 0
behaves same as unspecified one.@Parameter(property="trimStackTrace", defaultValue="true") protected boolean trimStackTrace
@Component protected ArtifactResolver artifactResolver
@Component protected ArtifactFactory artifactFactory
@Parameter(defaultValue="${project.pluginArtifactRepositories}") protected List<ArtifactRepository> remoteRepositories
@Component protected ArtifactMetadataSource metadataSource
@Parameter(property="disableXmlReport", defaultValue="false") protected boolean disableXmlReport
@Parameter(property="enableAssertions", defaultValue="true") protected boolean enableAssertions
@Component protected MavenSession session
@Parameter(property="objectFactory") protected String objectFactory
@Parameter(defaultValue="${session.parallel}", readonly=true) protected Boolean parallelMavenExecution
@Component protected ToolchainManager toolchainManager
public static final String THREAD_NUMBER_PLACEHOLDER
public static final String FORK_NUMBER_PLACEHOLDER
protected abstract String getPluginName()
protected abstract int getRerunFailingTestsCount()
public void execute() throws MojoExecutionException, MojoFailureException
execute
in interface Mojo
MojoExecutionException
MojoFailureException
protected abstract boolean isSkipExecution()
protected void executeAfterPreconditionsChecked(DefaultScanResult scanResult) throws MojoExecutionException, MojoFailureException
protected List<ProviderInfo> createProviders() throws MojoFailureException, MojoExecutionException
public void showToLog(SurefireProperties props, Log log, String setting)
public static SurefireProperties createCopyAndReplaceForkNumPlaceholder(SurefireProperties effectiveSystemProperties, int threadNumber)
protected void cleanupForkConfiguration(ForkConfiguration forkConfiguration)
protected abstract void handleSummary(RunResult summary, Exception firstForkException) throws MojoExecutionException, MojoFailureException
protected void logReportsDirectory()
protected boolean isAnyConcurrencySelected()
protected boolean isAnyGroupsSelected()
protected ForkStarter createForkStarter(ProviderInfo provider, ForkConfiguration forkConfiguration, ClassLoaderConfiguration classLoaderConfiguration, RunOrderParameters runOrderParameters, Log log) throws MojoExecutionException, MojoFailureException
protected InPluginVMSurefireStarter createInprocessStarter(ProviderInfo provider, ClassLoaderConfiguration classLoaderConfiguration, RunOrderParameters runOrderParameters) throws MojoExecutionException, MojoFailureException
protected ForkConfiguration getForkConfiguration()
protected int getEffectiveForkCount()
protected int convertWithCoreCount(String count)
protected void addPluginSpecificChecksumItems(ChecksumCalculator checksum)
protected boolean hasExecutedBefore()
protected ClassLoaderConfiguration getClassLoaderConfiguration(boolean isForking)
protected abstract String[] getDefaultIncludes()
public abstract List<String> getIncludes()
getIncludes
in interface SurefireExecutionParameters
public File getIncludesFile()
public abstract void setIncludes(List<String> includes)
setIncludes
in interface SurefireExecutionParameters
public List<String> getExcludes()
getExcludes
in interface SurefireExecutionParameters
public File getExcludesFile()
public void setExcludes(List<String> excludes)
setExcludes
in interface SurefireExecutionParameters
public ArtifactRepository getLocalRepository()
getLocalRepository
in interface SurefireExecutionParameters
public void setLocalRepository(ArtifactRepository localRepository)
setLocalRepository
in interface SurefireExecutionParameters
public Properties getSystemProperties()
public void setSystemProperties(Properties systemProperties)
public void setSystemPropertyVariables(Map<String,String> systemPropertyVariables)
public File getSystemPropertiesFile()
public void setSystemPropertiesFile(File systemPropertiesFile)
public Properties getProperties()
public void setProperties(Properties properties)
public String getReportNameSuffix()
public void setReportNameSuffix(String reportNameSuffix)
public boolean isRedirectTestOutputToFile()
public void setRedirectTestOutputToFile(boolean redirectTestOutputToFile)
public Boolean getFailIfNoTests()
public void setFailIfNoTests(Boolean failIfNoTests)
public String getForkMode()
public void setForkMode(String forkMode)
public String getJvm()
public String getArgLine()
public void setArgLine(String argLine)
public void setEnvironmentVariables(Map<String,String> environmentVariables)
public File getWorkingDirectory()
public void setWorkingDirectory(File workingDirectory)
public boolean isChildDelegation()
public void setChildDelegation(boolean childDelegation)
public String getGroups()
public void setGroups(String groups)
public String getExcludedGroups()
public void setExcludedGroups(String excludedGroups)
public abstract File[] getSuiteXmlFiles()
public abstract void setSuiteXmlFiles(File[] suiteXmlFiles)
public String getJunitArtifactName()
public void setJunitArtifactName(String junitArtifactName)
public String getTestNGArtifactName()
public void setTestNGArtifactName(String testNGArtifactName)
public int getThreadCount()
public void setThreadCount(int threadCount)
public boolean getPerCoreThreadCount()
public void setPerCoreThreadCount(boolean perCoreThreadCount)
public boolean getUseUnlimitedThreads()
public void setUseUnlimitedThreads(boolean useUnlimitedThreads)
public String getParallel()
public void setParallel(String parallel)
public boolean isParallelOptimized()
public void setParallelOptimized(boolean parallelOptimized)
public int getThreadCountSuites()
public void setThreadCountSuites(int threadCountSuites)
public int getThreadCountClasses()
public void setThreadCountClasses(int threadCountClasses)
public int getThreadCountMethods()
public void setThreadCountMethods(int threadCountMethods)
public boolean isTrimStackTrace()
public void setTrimStackTrace(boolean trimStackTrace)
public ArtifactResolver getArtifactResolver()
public void setArtifactResolver(ArtifactResolver artifactResolver)
public ArtifactFactory getArtifactFactory()
public void setArtifactFactory(ArtifactFactory artifactFactory)
public List<ArtifactRepository> getRemoteRepositories()
public void setRemoteRepositories(List<ArtifactRepository> remoteRepositories)
public ArtifactMetadataSource getMetadataSource()
public void setMetadataSource(ArtifactMetadataSource metadataSource)
public boolean isDisableXmlReport()
public void setDisableXmlReport(boolean disableXmlReport)
public boolean isEnableAssertions()
public boolean effectiveIsEnableAssertions()
public void setEnableAssertions(boolean enableAssertions)
public MavenSession getSession()
public void setSession(MavenSession session)
public String getObjectFactory()
public void setObjectFactory(String objectFactory)
public ToolchainManager getToolchainManager()
public void setToolchainManager(ToolchainManager toolchainManager)
public boolean isMavenParallel()
public abstract String getRunOrder()
public abstract void setRunOrder(String runOrder)
public String[] getDependenciesToScan()
public void setDependenciesToScan(String[] dependenciesToScan)
public PluginDescriptor getPluginDescriptor()
public MavenProject getProject()
public void setProject(MavenProject project)
public File getTestSourceDirectory()
getTestSourceDirectory
in interface SurefireExecutionParameters
public void setTestSourceDirectory(File testSourceDirectory)
setTestSourceDirectory
in interface SurefireExecutionParameters
public String getForkCount()
public boolean isReuseForks()
public String[] getAdditionalClasspathElements()
public void setAdditionalClasspathElements(String[] additionalClasspathElements)
public String[] getClasspathDependencyExcludes()
public void setClasspathDependencyExcludes(String[] classpathDependencyExcludes)
public String getClasspathDependencyScopeExclude()
public void setClasspathDependencyScopeExclude(String classpathDependencyScopeExclude)
Copyright © 2004–2014 The Apache Software Foundation. All rights reserved.