Package org.testng
Interface ITestNGMethod
- All Superinterfaces:
Cloneable
Describes a TestNG annotated method and the instance on which it will be invoked.
This interface is not meant to be implemented by users.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFailedInvocationNumber
(int number) The list of invocation numbers that failed, which is only applicable for methods that have a data provider.void
addMethodDependedUpon
(String methodName) boolean
canRunFromClass
(IClass testClass) clone()
default Set<ITestNGMethod>
findMethodParameters
(XmlTest test) String[]
default CustomAttribute[]
String[]
org.testng.internal.ConstructorOrMethod
int
default IDataProviderMethod
long
getDate()
boolean
default org.testng.internal.IParameterInfo
String[]
String[]
getId()
long[]
Needed for serialization.int
int
Which invocation numbers of this method should be used (only applicable if it uses a data provider).long
Returns the method name.String[]
int
default Class<?>[]
int
The scheduling priority.getRealClass().getName() + "." + getMethodName()getRetryAnalyzer
(ITestResult result) Class<? extends IRetryAnalyzer>
int
int
long
default boolean
default boolean
boolean
boolean
void
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
default boolean
default boolean
boolean
isTest()
void
setDate
(long date) void
setDescription
(String description) void
void
setIgnoreMissingDependencies
(boolean ignore) void
setInterceptedPriority
(int priority) void
setInvocationCount
(int count) void
setInvocationNumbers
(List<Integer> numbers) void
setMissingGroup
(String group) void
setMoreInvocationChecker
(Callable<Boolean> moreInvocationChecker) void
setParameterInvocationCount
(int n) void
setPriority
(int priority) void
setRetryAnalyzerClass
(Class<? extends IRetryAnalyzer> clazz) void
setSkipFailedInvocations
(boolean skip) void
setTestClass
(ITestClass cls) Sets the test class having this method.void
setThreadPoolSize
(int threadPoolSize) void
setTimeOut
(long timeOut) boolean
default Set<ITestNGMethod>
-
Method Details
-
getRealClass
Class getRealClass()- Returns:
- The real class on which this method was declared (can be different from getMethod().getDeclaringClass() if the test method was defined in a superclass).
-
getTestClass
ITestClass getTestClass() -
setTestClass
Sets the test class having this method. This is not necessarily the declaring class.- Parameters:
cls
- The test class having this method.
-
getMethodName
String getMethodName()Returns the method name. This is needed for serialization because methods are not Serializable.- Returns:
- the method name.
-
getInstance
Object getInstance() -
getInstanceHashCodes
long[] getInstanceHashCodes()Needed for serialization.- Returns:
- The hashcode of instances
-
getGroups
String[] getGroups()- Returns:
- The groups this method belongs to, possibly added to the groups declared on the class.
-
getGroupsDependedUpon
String[] getGroupsDependedUpon()- Returns:
- The groups this method depends on, possibly added to the groups declared on the class.
-
getMissingGroup
String getMissingGroup()- Returns:
- If a group was not found.
-
setMissingGroup
-
getBeforeGroups
String[] getBeforeGroups() -
getAfterGroups
String[] getAfterGroups() -
getMethodsDependedUpon
String[] getMethodsDependedUpon()- Returns:
- The methods this method depends on, possibly added to the methods declared on the class.
-
downstreamDependencies
- Returns:
- - The set of methods that are dependent on the current method. This information can help in deciding what other TestNG methods will be skipped if the current method fails. If the current method is a configuration method, then an empty set is returned.
-
upstreamDependencies
- Returns:
- - The set of methods upon which the current method has a dependency. This information can help in deciding what all TestNG methods need to pass before the current method can be executed. If the current method is a configuration method, then an empty set is returned.
-
addMethodDependedUpon
-
isTest
boolean isTest()- Returns:
- true if this method was annotated with @Test
-
isBeforeMethodConfiguration
boolean isBeforeMethodConfiguration()- Returns:
- true if this method was annotated with @Configuration and beforeTestMethod = true
-
isAfterMethodConfiguration
boolean isAfterMethodConfiguration()- Returns:
- true if this method was annotated with @Configuration and beforeTestMethod = false
-
isBeforeClassConfiguration
boolean isBeforeClassConfiguration()- Returns:
- true if this method was annotated with @Configuration and beforeClassMethod = true
-
isAfterClassConfiguration
boolean isAfterClassConfiguration()- Returns:
- true if this method was annotated with @Configuration and beforeClassMethod = false
-
isBeforeSuiteConfiguration
boolean isBeforeSuiteConfiguration()- Returns:
- true if this method was annotated with @Configuration and beforeSuite = true
-
isAfterSuiteConfiguration
boolean isAfterSuiteConfiguration()- Returns:
- true if this method was annotated with @Configuration and afterSuite = true
-
isBeforeTestConfiguration
boolean isBeforeTestConfiguration()- Returns:
true
if this method is a @BeforeTest (@Configuration beforeTest=true)
-
isAfterTestConfiguration
boolean isAfterTestConfiguration()- Returns:
true
if this method is an @AfterTest (@Configuration afterTest=true)
-
isBeforeGroupsConfiguration
boolean isBeforeGroupsConfiguration() -
isAfterGroupsConfiguration
boolean isAfterGroupsConfiguration() -
hasBeforeGroupsConfiguration
default boolean hasBeforeGroupsConfiguration() -
hasAfterGroupsConfiguration
default boolean hasAfterGroupsConfiguration() -
getTimeOut
long getTimeOut()- Returns:
- The timeout in milliseconds.
-
setTimeOut
void setTimeOut(long timeOut) -
getInvocationCount
int getInvocationCount()- Returns:
- the number of times this method needs to be invoked.
-
setInvocationCount
void setInvocationCount(int count) -
getSuccessPercentage
int getSuccessPercentage()- Returns:
- the success percentage for this method (between 0 and 100).
-
getId
String getId()- Returns:
- The id of the thread this method was run in.
-
setId
-
getDate
long getDate() -
setDate
void setDate(long date) -
canRunFromClass
- Parameters:
testClass
- The test class- Returns:
- true if this ITestNGMethod can be invoked from within IClass.
-
isAlwaysRun
boolean isAlwaysRun()- Returns:
- true if this method is alwaysRun=true
-
getThreadPoolSize
int getThreadPoolSize()- Returns:
- the number of threads to be used when invoking the method on parallel
-
setThreadPoolSize
void setThreadPoolSize(int threadPoolSize) -
getEnabled
boolean getEnabled() -
getDescription
String getDescription() -
setDescription
-
incrementCurrentInvocationCount
void incrementCurrentInvocationCount() -
getCurrentInvocationCount
int getCurrentInvocationCount() -
setParameterInvocationCount
void setParameterInvocationCount(int n) -
getParameterInvocationCount
int getParameterInvocationCount() -
setMoreInvocationChecker
-
hasMoreInvocation
boolean hasMoreInvocation() -
clone
ITestNGMethod clone() -
getRetryAnalyzer
-
setRetryAnalyzerClass
-
getRetryAnalyzerClass
Class<? extends IRetryAnalyzer> getRetryAnalyzerClass() -
skipFailedInvocations
boolean skipFailedInvocations() -
setSkipFailedInvocations
void setSkipFailedInvocations(boolean skip) -
getInvocationTimeOut
long getInvocationTimeOut()- Returns:
- The time under which all invocationCount methods need to complete by.
-
ignoreMissingDependencies
boolean ignoreMissingDependencies() -
setIgnoreMissingDependencies
void setIgnoreMissingDependencies(boolean ignore) -
getInvocationNumbers
Which invocation numbers of this method should be used (only applicable if it uses a data provider). If this value is an empty list, use all the values returned from the data provider. These values are read from the XML file in the<include invocationNumbers="...">
tag.- Returns:
- The list of invocation numbers
-
setInvocationNumbers
-
addFailedInvocationNumber
void addFailedInvocationNumber(int number) The list of invocation numbers that failed, which is only applicable for methods that have a data provider.- Parameters:
number
- The invocation number that failed
-
getFailedInvocationNumbers
-
getPriority
int getPriority()The scheduling priority. Lower priorities get scheduled first.- Returns:
- The priority value
-
setPriority
void setPriority(int priority) -
getInterceptedPriority
int getInterceptedPriority() -
setInterceptedPriority
void setInterceptedPriority(int priority) -
getXmlTest
XmlTest getXmlTest()- Returns:
- the XmlTest this method belongs to.
-
getConstructorOrMethod
org.testng.internal.ConstructorOrMethod getConstructorOrMethod() -
findMethodParameters
- Parameters:
test
- - TheXmlTest
object.- Returns:
- the parameters found in the include tag, if any
-
getQualifiedName
String getQualifiedName()getRealClass().getName() + "." + getMethodName()- Returns:
- qualified name for this method
-
isDataDriven
default boolean isDataDriven() -
getFactoryMethodParamsInfo
default org.testng.internal.IParameterInfo getFactoryMethodParamsInfo()- Returns:
- - A
IParameterInfo
object that represents details about the parameters associated with the factory method.
-
getAttributes
- Returns:
- - An array of
CustomAttribute
that represents the custom attributes associated with a test.
-
getDataProviderMethod
- Returns:
- - An
IDataProviderMethod
for a data provider powered test method andnull
otherwise.
-
getParameterTypes
-
isIgnoreFailure
default boolean isIgnoreFailure()- Returns:
- -
true
if the configuration failure arising out of this method should be ignored.
-