public class JUnit4
extends org.apache.tools.ant.Task
EventBus
and receive full information
about tests' execution (including skipped, assumption-skipped tests, streamlined
output and error stream chunks, etc.).RandomizedRunner
(randomization seed is passed to
children JVMs).Modifier and Type | Class and Description |
---|---|
static class |
JUnit4.ExtendedPropertySet
A
PropertySet with an additional
attribute specifying whether or not empty values should be propagated or ignored. |
static class |
JUnit4.ExtendedVariable
A
Environment.Variable with an additional
attribute specifying whether or not empty values should be propagated or ignored. |
static class |
JUnit4.JvmOutputAction
What to do on JVM output?
|
static class |
JUnit4.NoTestsAction
What to do when there were no executed tests (all ignored or none at all?).
|
Modifier and Type | Field and Description |
---|---|
static String |
ANTLIB_RESOURCE_NAME
Name of the antlib resource inside JUnit4 JAR.
|
static float |
DEFAULT_DYNAMIC_ASSIGNMENT_RATIO
Default value of
setDynamicAssignmentRatio(float) |
static boolean |
DEFAULT_HALT_ON_FAILURE
Default value of
setHaltOnFailure(boolean) . |
static boolean |
DEFAULT_ISOLATE_WORKING_DIRECTORIES
Default value of
setIsolateWorkingDirectories(boolean) . |
static String |
DEFAULT_PARALLELISM
Default value of
setParallelism(java.lang.String) . |
static boolean |
DEFAULT_PRINT_SUMMARY
Default value of
setPrintSummary(boolean) . |
static boolean |
DEFAULT_SHUFFLE_ON_SLAVE
Default value of
setShuffleOnSlave(boolean) . |
static boolean |
DEFAULT_SYSOUTS
Default value of
setSysouts(boolean) . |
static boolean |
DEFAULT_UNIQUE_SUITE_NAME
Default value of
setUniqueSuiteNames(boolean) |
EnumSet<JUnit4.JvmOutputAction> |
jvmOutputAction |
static Object |
PARALLELISM_AUTO |
static String |
PARALLELISM_MAX |
Constructor and Description |
---|
JUnit4() |
Modifier and Type | Method and Description |
---|---|
void |
add(org.apache.tools.ant.types.ResourceCollection rc)
Adds a set of tests based on pattern matching.
|
void |
addAssertions(org.apache.tools.ant.types.Assertions asserts)
Add assertions to tests execution.
|
void |
addConfiguredSysproperty(JUnit4.ExtendedVariable sysp)
Adds a system property to any forked JVM.
|
void |
addConfiguredSyspropertyset(JUnit4.ExtendedPropertySet sysp)
Adds a set of properties that will be used as system properties that tests
can access.
|
void |
addEnv(JUnit4.ExtendedVariable var)
Adds an environment variable; used when forking.
|
void |
addFileSet(org.apache.tools.ant.types.FileSet fs)
Adds a set of tests based on pattern matching.
|
BalancersList |
createBalancers()
Creates a new list of balancers.
|
Object |
createBatchtest() |
org.apache.tools.ant.types.Path |
createBootclasspath()
Adds a path to the bootclasspath.
|
org.apache.tools.ant.types.Path |
createClasspath()
Adds path to classpath used for tests.
|
Object |
createFormatter() |
org.apache.tools.ant.types.Commandline.Argument |
createJvmarg()
Add an additional argument to any forked JVM.
|
ListenersList |
createListeners()
Creates a new list of listeners.
|
Object |
createTest() |
void |
execute() |
String |
getSeed() |
boolean |
isUniqueSuiteNames() |
void |
setClonevm(String v) |
void |
setDir(File dir)
The directory to invoke forked VMs in.
|
void |
setDynamicAssignmentRatio(float ratio)
Specifies the ratio of suites moved to dynamic assignment list.
|
void |
setEnableTestListenerEvents(String v) |
void |
setErrorproperty(String v) |
void |
setFailureProperty(String failureProperty)
Property to set to "true" if there is a failure in a test.
|
void |
setFiltertrace(boolean filterTrace) |
void |
setFork(boolean fork) |
void |
setForkmode(String forkMode) |
void |
setHaltOnError(boolean haltOnError) |
void |
setHaltOnFailure(boolean haltOnFailure)
Stop the build process if there were failures or errors during test execution.
|
void |
setHeartbeat(long heartbeat)
Sets the heartbeat used to detect inactive/ hung forked tests (JVMs) to the given
number of seconds.
|
void |
setIfNoTests(String value)
What to do when no tests were executed (all tests were ignored)?
|
void |
setIncludeantruntime(String v) |
void |
setIsolateWorkingDirectories(boolean isolateWorkingDirectories)
If set to
true each slave JVM gets a separate working directory
under whatever is set in setDir(File) . |
void |
setJvm(String jvm)
The command used to invoke the Java Virtual Machine, default is 'java'.
|
void |
setJvmOutputAction(String jvmOutputActions)
What should be done on unexpected JVM output? JVM may write directly to the
original descriptors, bypassing redirections of System.out and System.err.
|
void |
setLeaveTemporary(boolean leaveTemporary)
Set to true to leave temporary files for diagnostics.
|
void |
setLogfailedtests(String v) |
void |
setMaxmemory(String max)
Set the maximum memory to be used by all forked JVMs.
|
void |
setNewEnvironment(boolean v)
Do not propagate the old environment when new environment variables are specified.
|
void |
setOutputtoformatters(String v) |
void |
setParallelism(String parallelism)
The number of parallel slaves.
|
void |
setPrefix(String prefix)
Initializes custom prefix for all junit4 properties.
|
void |
setPrintSummary(boolean printSummary)
Prints the summary of all executed, ignored etc.
|
void |
setProject(org.apache.tools.ant.Project project) |
void |
setReloading(String v) |
void |
setSeed(String randomSeed)
Initial random seed used for shuffling test suites and other sources
of pseudo-randomness.
|
void |
setShowoutput(String v) |
void |
setShuffleOnSlave(boolean shuffle)
Predictably shuffle tests order after balancing.
|
void |
setStatsPropertyPrefix(String statsPropertyPrefix)
Sets the property prefix to which test statistics are saved.
|
void |
setSysouts(boolean sysouts)
If set to true, any sysout and syserr calls will be written to original
output and error streams (and in effect will appear as "jvm output".
|
void |
setTempDir(File tempDir)
The directory to store temporary files in.
|
void |
setTimeout(String v) |
void |
setUniqueSuiteNames(boolean uniqueSuiteNames)
Allow or disallow duplicate suite names in resource collections.
|
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
public static final String ANTLIB_RESOURCE_NAME
public static final Object PARALLELISM_AUTO
setParallelism(String)
public static final String PARALLELISM_MAX
setParallelism(String)
,
Constant Field Valuespublic static final boolean DEFAULT_SHUFFLE_ON_SLAVE
setShuffleOnSlave(boolean)
.public static final String DEFAULT_PARALLELISM
setParallelism(java.lang.String)
.public static final boolean DEFAULT_PRINT_SUMMARY
setPrintSummary(boolean)
.public static final boolean DEFAULT_HALT_ON_FAILURE
setHaltOnFailure(boolean)
.public static final boolean DEFAULT_ISOLATE_WORKING_DIRECTORIES
setIsolateWorkingDirectories(boolean)
.public static final float DEFAULT_DYNAMIC_ASSIGNMENT_RATIO
setDynamicAssignmentRatio(float)
public static final boolean DEFAULT_SYSOUTS
setSysouts(boolean)
.public static final boolean DEFAULT_UNIQUE_SUITE_NAME
setUniqueSuiteNames(boolean)
public EnumSet<JUnit4.JvmOutputAction> jvmOutputAction
setJvmOutputAction(String)
public void setJvmOutputAction(String jvmOutputActions)
Allowed values (any comma-delimited combination of): JUnit4.JvmOutputAction
constants.
public void setSysouts(boolean sysouts)
public void setUniqueSuiteNames(boolean uniqueSuiteNames)
true
because certain ANT-compatible report types (like XML reports)
will have a problem with duplicate suite names (will overwrite files).public boolean isUniqueSuiteNames()
setUniqueSuiteNames(boolean)
public void setDynamicAssignmentRatio(float ratio)
A ratio of 0 means only static assignments are used. A ratio of 1 means only dynamic assignments are used.
The list of dynamic assignments is sorted by decreasing cost (always) and
is inherently prone to race conditions in distributing suites. Should there
be an error based on suite-dependency it will not be directly repeatable. In such
case use the per-slave-jvm list of suites file dumped to disk for each slave JVM.
(see setLeaveTemporary(boolean)
).
public void setParallelism(String parallelism)
Runtime.availableProcessors()
or
"auto" for sensible defaults depending on the number of cores.
The default is a single subprocess.
Note that this setting forks physical JVM processes so it multiplies the requirements for heap memory, IO, etc.
public void setFailureProperty(String failureProperty)
public void setNewEnvironment(boolean v)
public void setSeed(String randomSeed)
The seed's format is compatible with RandomizedRunner
so that
seed can be fixed for suites and methods alike.
public void setPrefix(String prefix)
public String getSeed()
setSeed(String)
public void setShuffleOnSlave(boolean shuffle)
public void setProject(org.apache.tools.ant.Project project)
setProject
in class org.apache.tools.ant.ProjectComponent
public void setPrintSummary(boolean printSummary)
public void setHaltOnFailure(boolean haltOnFailure)
public void setMaxmemory(String max)
max
- the value as defined by -mx or -Xmx in the java
command line options.public void setLeaveTemporary(boolean leaveTemporary)
public org.apache.tools.ant.types.Commandline.Argument createJvmarg()
public void setDir(File dir)
public void setTempDir(File tempDir)
public void setIfNoTests(String value)
JUnit4.NoTestsAction
public void addConfiguredSysproperty(JUnit4.ExtendedVariable sysp)
public void addConfiguredSyspropertyset(JUnit4.ExtendedPropertySet sysp)
public void setJvm(String jvm)
public void setIsolateWorkingDirectories(boolean isolateWorkingDirectories)
true
each slave JVM gets a separate working directory
under whatever is set in setDir(File)
. The directory naming for each slave
follows: "Snum", where num is slave's number. Directories are created
automatically and removed unless setLeaveTemporary(boolean)
is set to
true
.public void addEnv(JUnit4.ExtendedVariable var)
public void addFileSet(org.apache.tools.ant.types.FileSet fs)
public void add(org.apache.tools.ant.types.ResourceCollection rc)
public ListenersList createListeners()
public void addAssertions(org.apache.tools.ant.types.Assertions asserts)
public BalancersList createBalancers()
public org.apache.tools.ant.types.Path createClasspath()
public org.apache.tools.ant.types.Path createBootclasspath()
public void setFork(boolean fork)
public void setForkmode(String forkMode)
public void setHaltOnError(boolean haltOnError)
public void setFiltertrace(boolean filterTrace)
public void setTimeout(String v)
public void setIncludeantruntime(String v)
public void setShowoutput(String v)
public void setOutputtoformatters(String v)
public void setReloading(String v)
public void setClonevm(String v)
public void setErrorproperty(String v)
public void setLogfailedtests(String v)
public void setEnableTestListenerEvents(String v)
public Object createFormatter()
public Object createTest()
public Object createBatchtest()
public void setHeartbeat(long heartbeat)
TextReport
report will
emit heartbeat information (to a file or console).
Setting the heartbeat to zero means no detection.
public void setStatsPropertyPrefix(String statsPropertyPrefix)
public void execute() throws org.apache.tools.ant.BuildException
execute
in class org.apache.tools.ant.Task
org.apache.tools.ant.BuildException
Copyright © 2011–2015 Carrot Search s.c.. All rights reserved.