Package org.testng
Class TestNGAntTask
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.testng.TestNGAntTask
- All Implemented Interfaces:
Cloneable
public class TestNGAntTask
extends org.apache.tools.ant.Task
TestNG settings:
- classfileset (inner)
- classfilesetref (attribute)
- xmlfileset (inner)
- xmlfilesetref (attribute)
- enableAssert (attribute)
- excludedGroups (attribute)
- groups (attribute)
- junit (attribute)
- listener (attribute)
- outputdir (attribute)
- parallel (attribute)
- reporter (attribute)
- sourcedir (attribute)
- sourcedirref (attribute)
- suitename (attribute)
- suiterunnerclass (attribute)
- target (attribute)
- testjar (attribute)
- testname (attribute)
- threadcount (attribute)
- dataproviderthreadcount (attribute)
- verbose (attribute)
- testrunfactory (attribute)
- configFailurepolicy (attribute)
- randomizeSuites (attribute)
- methodselectors (attribute)
- classpath (inner)
- classpathref (attribute)
- jvm (attribute)
- workingDir (attribute)
- env (inner)
- sysproperty (inner)
- propertyset (inner)
- jvmarg (inner)
- timeout (attribute)
- haltonfailure (attribute)
- onHaltTarget (attribute)
- failureProperty (attribute)
- haltonFSP (attribute)
- FSPproperty (attribute)
- haltonskipped (attribute)
- skippedProperty (attribute)
- testRunnerFactory (attribute)
- dumpCommand (boolean)
- dumpEnv (boolean)
- dumpSys (boolean)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumprivate static classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate static final Loggerprotected booleanprotected List<org.apache.tools.ant.types.ResourceCollection> protected Stringprotected Stringprivate booleanprotected booleanTrue if the temporary file created by the Ant Task for command line parameters to TestNG should be preserved after execution.private booleanprivate booleanprotected org.apache.tools.ant.types.Environmentprotected Stringprotected Stringprotected Stringprotected booleanprotected booleanprotected booleanprivate booleanprotected Stringprotected org.apache.tools.ant.types.CommandlineJavaprotected StringThe suite runner name (defaults to TestNG.class.getName().private Stringprivate Stringprotected Stringprotected Fileprotected Stringprotected Booleanprivate Booleanprotected Stringprivate Stringprivate Integerprotected Fileprivate Stringprivate Stringprotected Stringprotected Stringprivate Integerprivate Integerprotected Fileprotected List<org.apache.tools.ant.types.ResourceCollection> private Stringprivate TestNGAntTask.Modeprivate List<AntReporterConfig> The list of report listeners added via <reporter> sub-element of the Ant taskFields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapperFields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidactOnResult(int exitValue, boolean wasKilled) private voidprivate voidaddBooleanIfTrue(List<String> argv, String name, Boolean value) voidaddClassfileset(org.apache.tools.ant.types.FileSet fs) voidaddConfiguredPropertySet(org.apache.tools.ant.types.PropertySet sysPropertySet) Add the referenced property set as system properties for the TestNG JVM.voidaddConfiguredReporter(AntReporterConfig reporterConfig) private voidaddDefaultListeners(List<String> argv) voidaddEnv(org.apache.tools.ant.types.Environment.Variable var) Adds an environment variable; used when forking.private voidaddFileIfFile(List<String> argv, String name, File file) private voidaddFilesOfRCollection(List<String> argv, String name, List<org.apache.tools.ant.types.ResourceCollection> resources) private voidaddIntegerIfNotNull(List<String> argv, String name, Integer value) private voidprivate voidaddOutputDir(List<String> argv) private voidaddReporterConfigs(List<String> argv) private voidaddStringIfNotBlank(List<String> argv, String name, String value) private voidaddStringIfNotNull(List<String> argv, String name, String value) voidaddSysproperty(org.apache.tools.ant.types.Environment.Variable sysp) private voidaddXmlFiles(List<String> argv) voidaddXmlfileset(org.apache.tools.ant.types.FileSet fs) private org.apache.tools.ant.types.FileSetappendClassSelector(org.apache.tools.ant.types.FileSet fs) org.apache.tools.ant.types.PathAdds a path to the bootclasspath.org.apache.tools.ant.types.PathAdds path to classpath used for tests.org.apache.tools.ant.types.Commandline.Argumentprivate org.apache.tools.ant.types.ResourceCollectioncreateResourceCollection(org.apache.tools.ant.types.Reference ref) protected org.apache.tools.ant.taskdefs.ExecuteWatchdogprivate voidprivate voidprivate voiddumpCommand(String fileName) voidexecute()Launches TestNG in a new JVM.protected intexecuteAsForked(org.apache.tools.ant.types.CommandlineJava cmd, org.apache.tools.ant.taskdefs.ExecuteWatchdog watchdog) Executes the command line as a new process.private voidexecuteHaltTarget(int exitValue) Executes the target, if any, that user designates executing before failing the testprivate FilefindJar()private StringReturns the list of files corresponding to the resource collectionprotected org.apache.tools.ant.types.CommandlineJavaprotected voidhandleOutput(String output) private voidprintDebugInfo(String fileName) private voidreadAndPrintFile(String fileName) voidsetClassfilesetRef(org.apache.tools.ant.types.Reference ref) voidsetClasspath(org.apache.tools.ant.types.Path s) Set the classpath to be used when running the Java classvoidsetClasspathRef(org.apache.tools.ant.types.Reference r) Classpath to use, by reference.voidsetConfigFailurePolicy(String failurePolicy) voidsetDataProviderThreadCount(String dataproviderthreadCount) voidsetDelegateCommandSystemProperties(boolean value) voidsetDumpCommand(boolean verbose) voidsetDumpEnv(boolean verbose) Sets the flag to write onSystem.outthe Ant Environment properties.voidsetDumpSys(boolean verbose) Sets te flag to write onSystem.outthe system properties.voidsetEnableAssert(boolean flag) voidsetExcludedGroups(String groups) voidsetFailureProperty(String propertyName) voidsetForkJvm(boolean forkJvm) voidsetFSPProperty(String propertyName) voidvoidsetHaltonfailure(boolean value) voidsetHaltonFSP(boolean value) voidsetHaltonskipped(boolean value) voidsetIgnoreMissedTestNames(boolean ignoreMissedTestNames) voidsetJUnit(boolean value) voidSets a particular JVM to be used.voidsetListeners(String listeners) voidsetMethods(String methods) voidsetMethodSelectors(String methodSelectors) voidsetMode(TestNGAntTask.Mode mode) voidsetObjectFactory(String className) voidsetOnHaltTarget(String targetName) voidsetOutputDir(File dir) Sets the test output directoryvoidsetParallel(String parallel) voidsetRandomizeSuites(Boolean randomizeSuites) voidsetReporter(String listener) voidsetSkipFailedInvocationCounts(boolean skip) voidsetSkippedProperty(String propertyName) voidSets the suite namevoidSets the suite runner class to invokevoidvoidsetTestJar(File s) Sets the test jarvoidSets the test namevoidsetTestNames(String testNames) voidsetTestRunnerFactory(String testRunnerFactory) voidsetThreadCount(String threadCount) voidsetTimeout(Integer value) Set the timeout value (in milliseconds).voidvoidsetVerbose(Integer verbose) voidsetWorkingDir(File workingDir) The directory to invoke the VM in.voidsetXmlfilesetRef(org.apache.tools.ant.types.Reference ref) voidsetXmlPathInJar(String path) protected voidMethods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeMethods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
-
Field Details
-
m_javaCommand
protected org.apache.tools.ant.types.CommandlineJava m_javaCommand -
m_xmlFilesets
-
m_classFilesets
-
m_outputDir
-
m_testjar
-
m_workingDir
-
m_timeout
-
m_listeners
-
m_methodselectors
-
m_objectFactory
-
m_testRunnerFactory
-
m_delegateCommandSystemProperties
private boolean m_delegateCommandSystemProperties -
m_environment
protected org.apache.tools.ant.types.Environment m_environment -
m_mainClass
The suite runner name (defaults to TestNG.class.getName(). -
m_dump
protected boolean m_dumpTrue if the temporary file created by the Ant Task for command line parameters to TestNG should be preserved after execution. -
m_dumpEnv
private boolean m_dumpEnv -
m_dumpSys
private boolean m_dumpSys -
m_assertEnabled
protected boolean m_assertEnabled -
m_haltOnFailure
protected boolean m_haltOnFailure -
m_onHaltTarget
-
m_failurePropertyName
-
m_haltOnSkipped
protected boolean m_haltOnSkipped -
m_skippedPropertyName
-
m_haltOnFSP
protected boolean m_haltOnFSP -
m_fspPropertyName
-
m_includedGroups
-
m_excludedGroups
-
m_parallelMode
-
m_threadCount
-
m_dataproviderthreadCount
-
m_configFailurePolicy
-
m_randomizeSuites
-
m_useDefaultListeners
-
m_suiteName
-
m_testName
-
m_skipFailedInvocationCounts
-
m_methods
-
mode
-
forkJvm
private boolean forkJvm -
m_ignoreMissedTestNames
private boolean m_ignoreMissedTestNames -
LOGGER
-
reporterConfigs
The list of report listeners added via <reporter> sub-element of the Ant task -
m_testNames
-
m_verbose
-
m_suiteThreadPoolSize
-
m_xmlPathInJar
-
-
Constructor Details
-
TestNGAntTask
public TestNGAntTask()
-
-
Method Details
-
setParallel
-
setThreadCount
-
setDataProviderThreadCount
-
setUseDefaultListeners
-
setHaltonfailure
public void setHaltonfailure(boolean value) -
setOnHaltTarget
-
setFailureProperty
-
setHaltonskipped
public void setHaltonskipped(boolean value) -
setSkippedProperty
-
setHaltonFSP
public void setHaltonFSP(boolean value) -
setFSPProperty
-
setDelegateCommandSystemProperties
public void setDelegateCommandSystemProperties(boolean value) -
setDumpCommand
public void setDumpCommand(boolean verbose) - Parameters:
verbose- the flag to log the command line. When verbose is set to true the command line parameters are stored in a temporary file stored in the user's default temporary file directory. The file created is prefixed with "testng".
-
setDumpEnv
public void setDumpEnv(boolean verbose) Sets the flag to write onSystem.outthe Ant Environment properties.- Parameters:
verbose-truefor printing
-
setDumpSys
public void setDumpSys(boolean verbose) Sets te flag to write onSystem.outthe system properties.- Parameters:
verbose-truefor dumping the info
-
setEnableAssert
public void setEnableAssert(boolean flag) -
setWorkingDir
The directory to invoke the VM in.- Parameters:
workingDir- the directory to invoke the JVM from.
-
setJvm
Sets a particular JVM to be used. Default is 'java' and is solved byRuntime.exec().- Parameters:
jvm- the new jvm
-
setTimeout
Set the timeout value (in milliseconds).If the tests are running for more than this value, the tests will be canceled.
- Parameters:
value- the maximum time (in milliseconds) allowed before declaring the test as 'timed-out'
-
createJvmarg
public org.apache.tools.ant.types.Commandline.Argument createJvmarg() -
addSysproperty
public void addSysproperty(org.apache.tools.ant.types.Environment.Variable sysp) -
addEnv
public void addEnv(org.apache.tools.ant.types.Environment.Variable var) Adds an environment variable; used when forking.- Parameters:
var- The variable
-
createClasspath
public org.apache.tools.ant.types.Path createClasspath()Adds path to classpath used for tests.- Returns:
- reference to the classpath in the embedded java command line
-
createBootclasspath
public org.apache.tools.ant.types.Path createBootclasspath()Adds a path to the bootclasspath.- Returns:
- reference to the bootclasspath in the embedded java command line
-
setClasspath
public void setClasspath(org.apache.tools.ant.types.Path s) Set the classpath to be used when running the Java class- Parameters:
s- an Ant Path object containing the classpath.
-
setClasspathRef
public void setClasspathRef(org.apache.tools.ant.types.Reference r) Classpath to use, by reference.- Parameters:
r- a reference to an existing classpath
-
addXmlfileset
public void addXmlfileset(org.apache.tools.ant.types.FileSet fs) -
setXmlfilesetRef
public void setXmlfilesetRef(org.apache.tools.ant.types.Reference ref) -
addClassfileset
public void addClassfileset(org.apache.tools.ant.types.FileSet fs) -
setClassfilesetRef
public void setClassfilesetRef(org.apache.tools.ant.types.Reference ref) -
setTestNames
-
setIgnoreMissedTestNames
public void setIgnoreMissedTestNames(boolean ignoreMissedTestNames) -
setSuiteRunnerClass
Sets the suite runner class to invoke- Parameters:
s- the name of the suite runner class
-
setSuiteName
Sets the suite name- Parameters:
s- the name of the suite
-
setTestName
Sets the test name- Parameters:
s- the name of the test
-
setJUnit
public void setJUnit(boolean value) -
setMode
-
setForkJvm
public void setForkJvm(boolean forkJvm) -
setOutputDir
Sets the test output directory- Parameters:
dir- the name of directory
-
setTestJar
Sets the test jar- Parameters:
s- the name of test jar
-
setGroups
-
setExcludedGroups
-
setVerbose
-
setReporter
-
setObjectFactory
-
setTestRunnerFactory
-
setSuiteThreadPoolSize
-
setListeners
-
setMethodSelectors
-
setConfigFailurePolicy
-
setRandomizeSuites
-
setMethods
-
execute
public void execute() throws org.apache.tools.ant.BuildExceptionLaunches TestNG in a new JVM.- Overrides:
executein classorg.apache.tools.ant.Task- Throws:
org.apache.tools.ant.BuildException
-
createArguments
-
addDefaultListeners
-
addOutputDir
-
addReporterConfigs
-
addFilesOfRCollection
-
addListOfStringIfNotEmpty
-
addArgumentsIfNotEmpty
-
addFileIfFile
-
addBooleanIfTrue
-
addIntegerIfNotNull
-
addStringIfNotNull
-
addStringIfNotBlank
-
addXmlFiles
-
getSuiteFileNames
- Returns:
- the list of the XML file names. This method can be overridden by subclasses.
-
delegateCommandSystemProperties
private void delegateCommandSystemProperties() -
printDebugInfo
-
debug
-
actOnResult
protected void actOnResult(int exitValue, boolean wasKilled) -
executeHaltTarget
private void executeHaltTarget(int exitValue) Executes the target, if any, that user designates executing before failing the test -
executeAsForked
protected int executeAsForked(org.apache.tools.ant.types.CommandlineJava cmd, org.apache.tools.ant.taskdefs.ExecuteWatchdog watchdog) Executes the command line as a new process.- Parameters:
cmd- the command to executewatchdog- - AExecuteWatchdogobject.- Returns:
- the exit status of the subprocess or INVALID.
-
getJavaCommand
protected org.apache.tools.ant.types.CommandlineJava getJavaCommand()- Returns:
- the created (or create) the
CommandlineJava.
-
createWatchdog
protected org.apache.tools.ant.taskdefs.ExecuteWatchdog createWatchdog()- Returns:
nullif there is no timeout value, otherwise the watchdog instance.- Throws:
org.apache.tools.ant.BuildException- under unspecified circumstances- Since:
- Ant 1.2
-
validateOptions
protected void validateOptions() throws org.apache.tools.ant.BuildException- Throws:
org.apache.tools.ant.BuildException
-
createResourceCollection
private org.apache.tools.ant.types.ResourceCollection createResourceCollection(org.apache.tools.ant.types.Reference ref) -
appendClassSelector
private org.apache.tools.ant.types.FileSet appendClassSelector(org.apache.tools.ant.types.FileSet fs) -
findJar
-
fromURI
-
getFiles
private List<String> getFiles(List<org.apache.tools.ant.types.ResourceCollection> resources) throws org.apache.tools.ant.BuildException Returns the list of files corresponding to the resource collection- Parameters:
resources- - A list ofResourceCollection- Returns:
- the list of files corresponding to the resource collection
- Throws:
org.apache.tools.ant.BuildException
-
dumpCommand
-
readAndPrintFile
-
addConfiguredReporter
-
setSkipFailedInvocationCounts
public void setSkipFailedInvocationCounts(boolean skip) -
setXmlPathInJar
-
addConfiguredPropertySet
public void addConfiguredPropertySet(org.apache.tools.ant.types.PropertySet sysPropertySet) Add the referenced property set as system properties for the TestNG JVM.- Parameters:
sysPropertySet- A PropertySet of system properties.
-
handleOutput
- Overrides:
handleOutputin classorg.apache.tools.ant.Task
-