Top Description Methods
org.testng

public Interface ITestNGMethod

extends Cloneable
Known Direct Implementers
org.testng.internal.BaseTestMethod, org.testng.internal.ClonedMethod, org.testng.internal.LiteWeightTestNGMethod, org.testng.internal.WrappedTestNGMethod
Imports
java.util.List, .Map, .Set, java.util.concurrent.Callable, org.testng.annotations.CustomAttribute, org.testng.internal.ConstructorOrMethod, .IParameterInfo, org.testng.xml.XmlTest

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 TypeMethod and Description
public void
addFailedInvocationNumber(int
The invocation number that failed
number
)

The list of invocation numbers that failed, which is only applicable for methods that have a data provider.

public void
public boolean

Returns:

true if this ITestNGMethod can be invoked from within IClass.
canRunFromClass
(IClass
The test class
testClass
)

public ITestNGMethod
public default Set<ITestNGMethod>

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.
downstreamDependencies
()

public Map<String, String>

Returns:

the parameters found in the include tag, if any
findMethodParameters
(XmlTest
- The XmlTest object.
test
)

public String[]
public default CustomAttribute[]

Returns:

- An array of CustomAttribute that represents the custom attributes associated with a test.
getAttributes
()

public String[]
public ConstructorOrMethod
public int
public default IDataProviderMethod

Returns:

- An IDataProviderMethod for a data provider powered test method and null otherwise.
getDataProviderMethod
()

public long
public String
public boolean
public default IParameterInfo

Returns:

- A IParameterInfo object that represents details about the parameters associated with the factory method.
getFactoryMethodParamsInfo
()

public List<Integer>
public String[]

Returns:

The groups this method belongs to, possibly added to the groups declared on the class.
getGroups
()

public String[]

Returns:

The groups this method depends on, possibly added to the groups declared on the class.
getGroupsDependedUpon
()

public String

Returns:

The id of the thread this method was run in.
getId
()

public Object
public long[]

Returns:

The hashcode of instances
getInstanceHashCodes
()

Needed for serialization.

public int
public int

Returns:

the number of times this method needs to be invoked.
getInvocationCount
()

public List<Integer>

Returns:

The list of invocation numbers
getInvocationNumbers
()

Which invocation numbers of this method should be used (only applicable if it uses a data provider).

public long

Returns:

The time under which all invocationCount methods need to complete by.
getInvocationTimeOut
()

public String

Returns:

the method name.
getMethodName
()

Returns the method name.

public String[]

Returns:

The methods this method depends on, possibly added to the methods declared on the class.
getMethodsDependedUpon
()

public String

Returns:

If a group was not found.
getMissingGroup
()

public int
public default Class<?>[]
public int

Returns:

The priority value
getPriority
()

The scheduling priority.

public String

Returns:

qualified name for this method
getQualifiedName
()

getRealClass().getName() + "." + getMethodName()

public Class<T>

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).
getRealClass
()

public IRetryAnalyzer
public Class<? extends IRetryAnalyzer>
public int

Returns:

the success percentage for this method (between 0 and 100).
getSuccessPercentage
()

public ITestClass
public int

Returns:

the number of threads to be used when invoking the method on parallel
getThreadPoolSize
()

public long

Returns:

The timeout in milliseconds.
getTimeOut
()

public XmlTest

Returns:

the XmlTest this method belongs to.
getXmlTest
()

public default boolean
public default boolean
public boolean
public boolean
public void
public boolean

Returns:

true if this method was annotated with @Configuration and beforeClassMethod = false
isAfterClassConfiguration
()

public boolean
public boolean

Returns:

true if this method was annotated with @Configuration and beforeTestMethod = false
isAfterMethodConfiguration
()

public boolean

Returns:

true if this method was annotated with @Configuration and afterSuite = true
isAfterSuiteConfiguration
()

public boolean

Returns:

true if this method is an @AfterTest (@Configuration afterTest=true)
isAfterTestConfiguration
()

public boolean

Returns:

true if this method is alwaysRun=true
isAlwaysRun
()

public boolean

Returns:

true if this method was annotated with @Configuration and beforeClassMethod = true
isBeforeClassConfiguration
()

public boolean
public boolean

Returns:

true if this method was annotated with @Configuration and beforeTestMethod = true
isBeforeMethodConfiguration
()

public boolean

Returns:

true if this method was annotated with @Configuration and beforeSuite = true
isBeforeSuiteConfiguration
()

public boolean

Returns:

true if this method is a @BeforeTest (@Configuration beforeTest=true)
isBeforeTestConfiguration
()

public default boolean
public default boolean

Returns:

- true if the configuration failure arising out of this method should be ignored.
isIgnoreFailure
()

public boolean

Returns:

true if this method was annotated with @Test
isTest
()

public void
setDate(long date)

public void
setDescription(String description)

public void
public void
public void
setInterceptedPriority(int priority)

public void
setInvocationCount(int count)

public void
public void
public void
setMoreInvocationChecker(Callable<Boolean> moreInvocationChecker)

public void
public void
setPriority(int priority)

public void
public void
public void
setTestClass(ITestClass
The test class having this method.
cls
)

Sets the test class having this method.

public void
setThreadPoolSize(int threadPoolSize)

public void
setTimeOut(long timeOut)

public boolean
public default Set<ITestNGMethod>

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.
upstreamDependencies
()

Method Detail

addFailedInvocationNumberback to summary
public void addFailedInvocationNumber(int number)

The list of invocation numbers that failed, which is only applicable for methods that have a data provider.

Parameters
number:int

The invocation number that failed

addMethodDependedUponback to summary
public void addMethodDependedUpon(String methodName)
canRunFromClassback to summary
public boolean canRunFromClass(IClass testClass)
Parameters
testClass:IClass

The test class

Returns:boolean

true if this ITestNGMethod can be invoked from within IClass.

cloneback to summary
public ITestNGMethod clone()
downstreamDependenciesback to summary
public default Set<ITestNGMethod> downstreamDependencies()
Returns:Set<ITestNGMethod>

- 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.

findMethodParametersback to summary
public Map<String, String> findMethodParameters(XmlTest test)
Parameters
test:XmlTest

- The XmlTest object.

Returns:Map<String, String>

the parameters found in the include tag, if any

getAfterGroupsback to summary
public String[] getAfterGroups()
getAttributesback to summary
public default CustomAttribute[] getAttributes()
Returns:CustomAttribute[]

- An array of CustomAttribute that represents the custom attributes associated with a test.

getBeforeGroupsback to summary
public String[] getBeforeGroups()
getConstructorOrMethodback to summary
public ConstructorOrMethod getConstructorOrMethod()
getCurrentInvocationCountback to summary
public int getCurrentInvocationCount()
getDataProviderMethodback to summary
public default IDataProviderMethod getDataProviderMethod()
Returns:IDataProviderMethod

- An IDataProviderMethod for a data provider powered test method and null otherwise.

getDateback to summary
public long getDate()
getDescriptionback to summary
public String getDescription()
getEnabledback to summary
public boolean getEnabled()
getFactoryMethodParamsInfoback to summary
public default IParameterInfo getFactoryMethodParamsInfo()
Returns:IParameterInfo

- A IParameterInfo object that represents details about the parameters associated with the factory method.

getFailedInvocationNumbersback to summary
public List<Integer> getFailedInvocationNumbers()
getGroupsback to summary
public String[] getGroups()
Returns:String[]

The groups this method belongs to, possibly added to the groups declared on the class.

getGroupsDependedUponback to summary
public String[] getGroupsDependedUpon()
Returns:String[]

The groups this method depends on, possibly added to the groups declared on the class.

getIdback to summary
public String getId()
Returns:String

The id of the thread this method was run in.

getInstanceback to summary
public Object getInstance()
getInstanceHashCodesback to summary
public long[] getInstanceHashCodes()

Needed for serialization.

Returns:long[]

The hashcode of instances

getInterceptedPriorityback to summary
public int getInterceptedPriority()
getInvocationCountback to summary
public int getInvocationCount()
Returns:int

the number of times this method needs to be invoked.

getInvocationNumbersback to summary
public List<Integer> 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:List<Integer>

The list of invocation numbers

getInvocationTimeOutback to summary
public long getInvocationTimeOut()
Returns:long

The time under which all invocationCount methods need to complete by.

getMethodNameback to summary
public String getMethodName()

Returns the method name. This is needed for serialization because methods are not Serializable.

Returns:String

the method name.

getMethodsDependedUponback to summary
public String[] getMethodsDependedUpon()
Returns:String[]

The methods this method depends on, possibly added to the methods declared on the class.

getMissingGroupback to summary
public String getMissingGroup()
Returns:String

If a group was not found.

getParameterInvocationCountback to summary
public int getParameterInvocationCount()
getParameterTypesback to summary
public default Class<?>[] getParameterTypes()
getPriorityback to summary
public int getPriority()

The scheduling priority. Lower priorities get scheduled first.

Returns:int

The priority value

getQualifiedNameback to summary
public String getQualifiedName()

getRealClass().getName() + "." + getMethodName()

Returns:String

qualified name for this method

getRealClassback to summary
public Class<T> getRealClass()
Returns:Class<T>

The real class on which this method was declared (can be different from getMethod().getDeclaringClass() if the test method was defined in a superclass).

getRetryAnalyzerback to summary
public IRetryAnalyzer getRetryAnalyzer(ITestResult result)
getRetryAnalyzerClassback to summary
public Class<? extends IRetryAnalyzer> getRetryAnalyzerClass()
getSuccessPercentageback to summary
public int getSuccessPercentage()
Returns:int

the success percentage for this method (between 0 and 100).

getTestClassback to summary
public ITestClass getTestClass()
getThreadPoolSizeback to summary
public int getThreadPoolSize()
Returns:int

the number of threads to be used when invoking the method on parallel

getTimeOutback to summary
public long getTimeOut()
Returns:long

The timeout in milliseconds.

getXmlTestback to summary
public XmlTest getXmlTest()
Returns:XmlTest

the XmlTest this method belongs to.

hasAfterGroupsConfigurationback to summary
public default boolean hasAfterGroupsConfiguration()
hasBeforeGroupsConfigurationback to summary
public default boolean hasBeforeGroupsConfiguration()
hasMoreInvocationback to summary
public boolean hasMoreInvocation()
ignoreMissingDependenciesback to summary
public boolean ignoreMissingDependencies()
incrementCurrentInvocationCountback to summary
public void incrementCurrentInvocationCount()
isAfterClassConfigurationback to summary
public boolean isAfterClassConfiguration()
Returns:boolean

true if this method was annotated with @Configuration and beforeClassMethod = false

isAfterGroupsConfigurationback to summary
public boolean isAfterGroupsConfiguration()
isAfterMethodConfigurationback to summary
public boolean isAfterMethodConfiguration()
Returns:boolean

true if this method was annotated with @Configuration and beforeTestMethod = false

isAfterSuiteConfigurationback to summary
public boolean isAfterSuiteConfiguration()
Returns:boolean

true if this method was annotated with @Configuration and afterSuite = true

isAfterTestConfigurationback to summary
public boolean isAfterTestConfiguration()
Returns:boolean

true if this method is an @AfterTest (@Configuration afterTest=true)

isAlwaysRunback to summary
public boolean isAlwaysRun()
Returns:boolean

true if this method is alwaysRun=true

isBeforeClassConfigurationback to summary
public boolean isBeforeClassConfiguration()
Returns:boolean

true if this method was annotated with @Configuration and beforeClassMethod = true

isBeforeGroupsConfigurationback to summary
public boolean isBeforeGroupsConfiguration()
isBeforeMethodConfigurationback to summary
public boolean isBeforeMethodConfiguration()
Returns:boolean

true if this method was annotated with @Configuration and beforeTestMethod = true

isBeforeSuiteConfigurationback to summary
public boolean isBeforeSuiteConfiguration()
Returns:boolean

true if this method was annotated with @Configuration and beforeSuite = true

isBeforeTestConfigurationback to summary
public boolean isBeforeTestConfiguration()
Returns:boolean

true if this method is a @BeforeTest (@Configuration beforeTest=true)

isDataDrivenback to summary
public default boolean isDataDriven()
isIgnoreFailureback to summary
public default boolean isIgnoreFailure()
Returns:boolean

- true if the configuration failure arising out of this method should be ignored.

isTestback to summary
public boolean isTest()
Returns:boolean

true if this method was annotated with @Test

setDateback to summary
public void setDate(long date)
setDescriptionback to summary
public void setDescription(String description)
setIdback to summary
public void setId(String id)
setIgnoreMissingDependenciesback to summary
public void setIgnoreMissingDependencies(boolean ignore)
setInterceptedPriorityback to summary
public void setInterceptedPriority(int priority)
setInvocationCountback to summary
public void setInvocationCount(int count)
setInvocationNumbersback to summary
public void setInvocationNumbers(List<Integer> numbers)
setMissingGroupback to summary
public void setMissingGroup(String group)
setMoreInvocationCheckerback to summary
public void setMoreInvocationChecker(Callable<Boolean> moreInvocationChecker)
setParameterInvocationCountback to summary
public void setParameterInvocationCount(int n)
setPriorityback to summary
public void setPriority(int priority)
setRetryAnalyzerClassback to summary
public void setRetryAnalyzerClass(Class<? extends IRetryAnalyzer> clazz)
setSkipFailedInvocationsback to summary
public void setSkipFailedInvocations(boolean skip)
setTestClassback to summary
public void setTestClass(ITestClass cls)

Sets the test class having this method. This is not necessarily the declaring class.

Parameters
cls:ITestClass

The test class having this method.

setThreadPoolSizeback to summary
public void setThreadPoolSize(int threadPoolSize)
setTimeOutback to summary
public void setTimeOut(long timeOut)
skipFailedInvocationsback to summary
public boolean skipFailedInvocations()
upstreamDependenciesback to summary
public default Set<ITestNGMethod> upstreamDependencies()
Returns:Set<ITestNGMethod>

- 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.