public class TestNG extends Object
usage()
Modifier and Type | Class and Description |
---|---|
static class |
TestNG.ExitCodeListener |
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_COMMAND_LINE_SUITE_NAME
The default name for a suite launched from the command line
|
static String |
DEFAULT_COMMAND_LINE_TEST_NAME
The default name for a test launched from the command line
|
static String |
DEFAULT_OUTPUTDIR
The default name of the result's output directory (keep public, used by Eclipse).
|
static Integer |
DEFAULT_VERBOSE |
protected static int |
HAS_FAILURE |
protected static int |
HAS_FSP |
protected static int |
HAS_NO_TEST |
protected static int |
HAS_SKIPPED |
protected long |
m_end |
protected long |
m_start |
protected List<org.testng.xml.XmlSuite> |
m_suites |
protected boolean |
m_useDefaultListeners |
static String |
SHOW_TESTNG_STACK_FRAMES
System properties
|
static String |
TEST_CLASSPATH |
Constructor and Description |
---|
TestNG()
Default constructor.
|
TestNG(boolean useDefaultListeners)
Used by maven2 to have 0 output of any kind come out
of testng.
|
Modifier and Type | Method and Description |
---|---|
void |
addClassLoader(ClassLoader loader)
Add a class loader to the searchable loaders.
|
void |
addExecutionListener(org.testng.IExecutionListener l) |
void |
addInvokedMethodListener(org.testng.IInvokedMethodListener listener) |
void |
addListener(org.testng.IInvokedMethodListener listener) |
void |
addListener(org.testng.IReporter listener) |
void |
addListener(org.testng.ISuiteListener listener) |
void |
addListener(org.testng.ITestListener listener) |
void |
addListener(Object listener) |
void |
addMethodSelector(String className,
int priority) |
protected void |
configure(org.testng.CommandLineArgs cla)
Configure the TestNG instance based on the command line parameters.
|
void |
configure(Map cmdLineArgs)
Deprecated.
use new configure(CommandLineArgs) method
|
org.testng.IAnnotationTransformer |
getAnnotationTransformer() |
String |
getConfigFailurePolicy()
Returns the configuration failure policy.
|
protected org.testng.internal.IConfiguration |
getConfiguration() |
static TestNG |
getDefault()
Deprecated.
since 5.1
|
String |
getDefaultSuiteName() |
String |
getDefaultTestName() |
protected long |
getEnd() |
String |
getOutputDirectory() |
Set<org.testng.IReporter> |
getReporters() |
List<org.testng.ITestNGListener> |
getServiceLoaderListeners() |
protected long |
getStart() |
int |
getStatus() |
List<org.testng.ISuiteListener> |
getSuiteListeners() |
Integer |
getSuiteThreadPoolSize() |
List<org.testng.ITestListener> |
getTestListeners() |
boolean |
hasFailure() |
boolean |
hasFailureWithinSuccessPercentage() |
boolean |
hasSkip() |
void |
initializeSuitesAndJarFile() |
static boolean |
isJdk14()
Deprecated.
|
static void |
main(String[] argv)
The TestNG entry point for command line execution.
|
static TestNG |
privateMain(String[] argv,
org.testng.ITestListener listener)
Note: this method is not part of the public API and is meant for internal usage only.
|
void |
run()
Run TestNG.
|
List<org.testng.ISuite> |
runSuitesLocally()
This needs to be public for maven2, for now..At least
until an alternative mechanism is found.
|
void |
setAnnotationTransformer(org.testng.IAnnotationTransformer t) |
void |
setCommandLineSuite(org.testng.xml.XmlSuite suite) |
void |
setConfigFailurePolicy(String failurePolicy)
Sets the policy for whether or not to ever invoke a configuration method again after
it has failed once.
|
void |
setDataProviderThreadCount(int count) |
void |
setDefaultSuiteName(String defaultSuiteName) |
void |
setDefaultTestName(String defaultTestName) |
void |
setExcludedGroups(String groups)
Define which groups will be excluded from this run.
|
void |
setGroupByInstances(boolean b) |
void |
setGroups(String groups)
Define which groups will be included from this run.
|
void |
setHasFailure(boolean hasFailure)
Deprecated.
since 5.1
|
void |
setHasFailureWithinSuccessPercentage(boolean hasFailureWithinSuccessPercentage)
Deprecated.
since 5.1
|
void |
setHasSkip(boolean hasSkip)
Deprecated.
since 5.1
|
void |
setJUnit(Boolean isJUnit)
Specify if this run should be made in JUnit mode
|
void |
setListenerClasses(List<Class> classes)
Define which listeners to user for this run.
|
void |
setMaster(String fileName)
Specify if this run should be in Master-Slave mode as Master
|
void |
setMethodInterceptor(org.testng.IMethodInterceptor i) |
void |
setMixed(Boolean isMixed)
Specify if this run should be made in mixed mode
|
void |
setObjectFactory(Class c) |
void |
setObjectFactory(org.testng.ITestObjectFactory factory) |
void |
setOutputDirectory(String outputdir)
Sets the output directory where the reports will be created.
|
void |
setParallel(String parallel)
Define whether this run will be run in parallel mode.
|
void |
setPreserveOrder(boolean b) |
void |
setRandomizeSuites(boolean randomizeSuites) |
void |
setServiceLoaderClassLoader(URLClassLoader ucl) |
void |
setSkipFailedInvocationCounts(Boolean skip) |
void |
setSlave(String fileName)
Specify if this run should be in Master-Slave mode as slave
|
void |
setSourcePath(String path)
This method is invoked by Maven's Surefire, only remove it once
Surefire has been modified to no longer call it.
|
void |
setSuiteThreadPoolSize(Integer suiteThreadPoolSize) |
void |
setTestClasses(Class[] classes)
Set the test classes to be run by this TestNG object.
|
void |
setTestJar(String jarPath)
Sets a jar containing a testng.xml file.
|
void |
setTestNames(List<String> testNames)
Only run the specified tests from the suite.
|
static void |
setTestNGVersion()
Deprecated.
The TestNG version is now established at load time. This
method is not required anymore and is now a no-op.
|
protected void |
setTestRunnerFactory(org.testng.ITestRunnerFactory itrf) |
void |
setTestSuites(List<String> suites)
Set the suites file names to be run by this TestNG object.
|
void |
setThreadCount(int threadCount)
Define the number of threads in the thread pool.
|
void |
setUseDefaultListeners(boolean useDefaultListeners)
If this method is passed true before run(), the default listeners
will not be used.
|
void |
setVerbose(int verbose)
Sets the level of verbosity.
|
void |
setXmlPathInJar(String xmlPathInJar)
Sets the path to the XML file in the test jar file.
|
void |
setXmlSuites(List<org.testng.xml.XmlSuite> suites)
Specifies the XmlSuite objects to run.
|
protected static void |
validateCommandLineParameters(org.testng.CommandLineArgs args)
Double check that the command line parameters are valid.
|
public static final String DEFAULT_COMMAND_LINE_SUITE_NAME
public static final String DEFAULT_COMMAND_LINE_TEST_NAME
public static final String DEFAULT_OUTPUTDIR
public static final String SHOW_TESTNG_STACK_FRAMES
public static final String TEST_CLASSPATH
protected List<org.testng.xml.XmlSuite> m_suites
protected boolean m_useDefaultListeners
protected static final int HAS_FAILURE
protected static final int HAS_SKIPPED
protected static final int HAS_FSP
protected static final int HAS_NO_TEST
public static final Integer DEFAULT_VERBOSE
protected long m_end
protected long m_start
public TestNG()
public TestNG(boolean useDefaultListeners)
useDefaultListeners
- Whether or not any default reports
should be added to tests.public int getStatus()
public void setOutputDirectory(String outputdir)
outputdir
- The directory.public void setUseDefaultListeners(boolean useDefaultListeners)
TestHTMLReporter
,
JUnitXMLReporter
,
XMLReporter
public void setTestJar(String jarPath)
jarPath
- public void setXmlPathInJar(String xmlPathInJar)
public void initializeSuitesAndJarFile()
public void setThreadCount(int threadCount)
public void setParallel(String parallel)
public void setCommandLineSuite(org.testng.xml.XmlSuite suite)
public void setTestClasses(Class[] classes)
classes
- An array of classes that contain TestNG annotations.public void addMethodSelector(String className, int priority)
public void setTestSuites(List<String> suites)
suites
- A list of paths to one more XML files defining the tests. For example:
TestNG tng = new TestNG(); Listsuites = Lists.newArrayList(); suites.add("c:/tests/testng1.xml"); suites.add("c:/tests/testng2.xml"); tng.setTestSuites(suites); tng.run();
public void setXmlSuites(List<org.testng.xml.XmlSuite> suites)
suites
- XmlSuite
public void setExcludedGroups(String groups)
groups
- A list of group names separated by a comma.public void setGroups(String groups)
groups
- A list of group names separated by a comma.protected void setTestRunnerFactory(org.testng.ITestRunnerFactory itrf)
public void setObjectFactory(Class c)
public void setObjectFactory(org.testng.ITestObjectFactory factory)
public void setListenerClasses(List<Class> classes)
classes
- A list of classes, which must be either ISuiteListener,
ITestListener or IReporterpublic void addListener(Object listener)
public void addListener(org.testng.IInvokedMethodListener listener)
public void addListener(org.testng.ISuiteListener listener)
public void addListener(org.testng.ITestListener listener)
public void addListener(org.testng.IReporter listener)
public void addInvokedMethodListener(org.testng.IInvokedMethodListener listener)
public Set<org.testng.IReporter> getReporters()
public List<org.testng.ITestListener> getTestListeners()
public List<org.testng.ISuiteListener> getSuiteListeners()
public void setVerbose(int verbose)
verbose
- the verbosity level (0 to 10 where 10 is most detailed)
Actually, this is a lie: you can specify -1 and this will put TestNG
in debug mode (no longer slicing off stack traces and all).public void run()
public void addExecutionListener(org.testng.IExecutionListener l)
public List<org.testng.ISuite> runSuitesLocally()
protected org.testng.internal.IConfiguration getConfiguration()
public static void main(String[] argv)
argv
- the TestNG command line parameters.FileNotFoundException
public static TestNG privateMain(String[] argv, org.testng.ITestListener listener)
protected void configure(org.testng.CommandLineArgs cla)
public void setSuiteThreadPoolSize(Integer suiteThreadPoolSize)
public Integer getSuiteThreadPoolSize()
public void setRandomizeSuites(boolean randomizeSuites)
public void setSourcePath(String path)
@Deprecated public void configure(Map cmdLineArgs)
public void setTestNames(List<String> testNames)
public void setSkipFailedInvocationCounts(Boolean skip)
public void setMaster(String fileName)
fileName
- remote.properties pathpublic void setSlave(String fileName)
fileName
- remote.properties pathpublic void setJUnit(Boolean isJUnit)
isJUnit
- public void setMixed(Boolean isMixed)
@Deprecated public static void setTestNGVersion()
@Deprecated public static boolean isJdk14()
protected static void validateCommandLineParameters(org.testng.CommandLineArgs args)
public boolean hasFailure()
public boolean hasFailureWithinSuccessPercentage()
public boolean hasSkip()
public String getOutputDirectory()
public org.testng.IAnnotationTransformer getAnnotationTransformer()
public void setAnnotationTransformer(org.testng.IAnnotationTransformer t)
public String getDefaultSuiteName()
public void setDefaultSuiteName(String defaultSuiteName)
defaultSuiteName
- the defaultSuiteName to setpublic String getDefaultTestName()
public void setDefaultTestName(String defaultTestName)
defaultTestName
- the defaultTestName to setpublic void setConfigFailurePolicy(String failurePolicy)
XmlSuite
. The default
value is XmlSuite.SKIP
.failurePolicy
- the configuration failure policypublic String getConfigFailurePolicy()
@Deprecated public static TestNG getDefault()
@Deprecated public void setHasFailure(boolean hasFailure)
@Deprecated public void setHasFailureWithinSuccessPercentage(boolean hasFailureWithinSuccessPercentage)
@Deprecated public void setHasSkip(boolean hasSkip)
public void setMethodInterceptor(org.testng.IMethodInterceptor i)
public void setDataProviderThreadCount(int count)
public void addClassLoader(ClassLoader loader)
public void setPreserveOrder(boolean b)
protected long getStart()
protected long getEnd()
public void setGroupByInstances(boolean b)
public void setServiceLoaderClassLoader(URLClassLoader ucl)
public List<org.testng.ITestNGListener> getServiceLoaderListeners()
Copyright © 2011–2015. All rights reserved.