Package org.testng.internal
Class BaseTestMethod
- java.lang.Object
-
- org.testng.internal.BaseTestMethod
-
- All Implemented Interfaces:
java.lang.Cloneable
,ITestNGMethod
- Direct Known Subclasses:
ConfigurationMethod
,FactoryMethod
,JUnitTestMethod
,TestNGMethod
public abstract class BaseTestMethod extends java.lang.Object implements ITestNGMethod
Superclass to represent both @Test and @Configuration methods.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String[]
m_afterGroups
protected IAnnotationFinder
m_annotationFinder
protected java.lang.String[]
m_beforeGroups
protected java.util.concurrent.atomic.AtomicInteger
m_currentInvocationCount
protected long
m_date
protected java.lang.String[]
m_groups
protected java.lang.String[]
m_groupsDependedUpon
protected java.lang.String
m_id
protected ConstructorOrMethod
m_method
protected java.lang.Class<?>
m_methodClass
protected java.lang.String[]
m_methodsDependedUpon
protected ITestClass
m_testClass
The test class on which the test method was found.
-
Constructor Summary
Constructors Constructor Description BaseTestMethod(java.lang.String methodName, ConstructorOrMethod com, IAnnotationFinder annotationFinder, java.lang.Object instance)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addFailedInvocationNumber(int number)
The list of invocation numbers that failed, which is only applicable for methods that have a data provider.void
addMethodDependedUpon(java.lang.String method)
boolean
canRunFromClass(IClass testClass)
Returns if this ITestNGMethod can be invoked from within IClass.abstract ITestNGMethod
clone()
boolean
equals(java.lang.Object obj)
Compares two BaseTestMethod using the test class then the associated Java Method.java.util.Map<java.lang.String,java.lang.String>
findMethodParameters(XmlTest test)
java.lang.String[]
getAfterGroups()
protected IAnnotationFinder
getAnnotationFinder()
java.lang.String[]
getBeforeGroups()
Before and After groupsConstructorOrMethod
getConstructorOrMethod()
int
getCurrentInvocationCount()
long
getDate()
java.lang.String
getDescription()
boolean
getEnabled()
IParameterInfo
getFactoryMethodParamsInfo()
java.util.List<java.lang.Integer>
getFailedInvocationNumbers()
java.lang.String[]
getGroups()
java.lang.String[]
getGroupsDependedUpon()
protected IClass
getIClass()
java.lang.String
getId()
java.lang.Object
getInstance()
long[]
getInstanceHashCodes()
Needed for serialization.int
getInterceptedPriority()
int
getInvocationCount()
java.util.List<java.lang.Integer>
getInvocationNumbers()
Which invocation numbers of this method should be used (only applicable if it uses a data provider).long
getInvocationTimeOut()
The time under which all invocationCount methods need to complete by.java.lang.String
getMethodName()
Returns the method name.java.lang.String[]
getMethodsDependedUpon()
java.lang.String
getMissingGroup()
If a group was not found.int
getParameterInvocationCount()
int
getPriority()
The scheduling priority.java.lang.String
getQualifiedName()
getRealClass().getName() + "." + getMethodName()java.lang.Class<?>
getRealClass()
IRetryAnalyzer
getRetryAnalyzer()
IRetryAnalyzer
getRetryAnalyzer(ITestResult result)
java.lang.Class<? extends IRetryAnalyzer>
getRetryAnalyzerClass()
protected java.lang.String
getSignature()
java.lang.String
getSimpleName()
protected java.lang.String[]
getStringArray(java.lang.String[] methodArray, java.lang.String[] classArray)
int
getSuccessPercentage()
Default value for successPercentage.ITestClass
getTestClass()
int
getThreadPoolSize()
long
getTimeOut()
XmlTest
getXmlTest()
int
hashCode()
This implementation returns the associated Java Method's hash code.boolean
hasMoreInvocation()
boolean
ignoreMissingDependencies()
void
incrementCurrentInvocationCount()
protected void
initBeforeAfterGroups(java.lang.Class<? extends ITestOrConfiguration> annotationClass, java.lang.String[] groups)
protected void
initGroups(java.lang.Class<? extends ITestOrConfiguration> annotationClass)
boolean
isAfterClassConfiguration()
boolean
isAfterGroupsConfiguration()
boolean
isAfterMethodConfiguration()
boolean
isAfterSuiteConfiguration()
boolean
isAfterTestConfiguration()
boolean
isAlwaysRun()
boolean
isBeforeClassConfiguration()
boolean
isBeforeGroupsConfiguration()
boolean
isBeforeMethodConfiguration()
boolean
isBeforeSuiteConfiguration()
boolean
isBeforeTestConfiguration()
boolean
isTest()
protected void
setAlwaysRun(boolean alwaysRun)
void
setDate(long date)
void
setDescription(java.lang.String description)
void
setEnabled(boolean enabled)
protected void
setGroups(java.lang.String[] groups)
protected void
setGroupsDependedUpon(java.lang.String[] groups, java.util.Collection<java.lang.String> xmlGroupDependencies)
void
setId(java.lang.String id)
void
setIgnoreMissingDependencies(boolean i)
void
setInterceptedPriority(int priority)
void
setInvocationCount(int counter)
No-op.void
setInvocationNumbers(java.util.List<java.lang.Integer> numbers)
void
setInvocationTimeOut(long timeOut)
protected void
setMethodsDependedUpon(java.lang.String[] methods)
void
setMissingGroup(java.lang.String group)
void
setMoreInvocationChecker(java.util.concurrent.Callable<java.lang.Boolean> moreInvocationChecker)
void
setParameterInvocationCount(int n)
void
setPriority(int priority)
void
setRetryAnalyzer(IRetryAnalyzer retryAnalyzer)
void
setRetryAnalyzerClass(java.lang.Class<? extends IRetryAnalyzer> clazz)
void
setSkipFailedInvocations(boolean s)
void
setTestClass(ITestClass tc)
Sets the test class having this method.void
setThreadPoolSize(int threadPoolSize)
No-op.void
setTimeOut(long timeOut)
void
setXmlTest(XmlTest xmlTest)
boolean
skipFailedInvocations()
java.lang.String
toString()
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.testng.ITestNGMethod
getAttributes, getDataProviderMethod, isDataDriven
-
-
-
-
Field Detail
-
m_testClass
protected ITestClass m_testClass
The test class on which the test method was found. Note that this is not necessarily the declaring class.
-
m_methodClass
protected final java.lang.Class<?> m_methodClass
-
m_method
protected final ConstructorOrMethod m_method
-
m_id
protected java.lang.String m_id
-
m_date
protected long m_date
-
m_annotationFinder
protected final IAnnotationFinder m_annotationFinder
-
m_groups
protected java.lang.String[] m_groups
-
m_groupsDependedUpon
protected java.lang.String[] m_groupsDependedUpon
-
m_methodsDependedUpon
protected java.lang.String[] m_methodsDependedUpon
-
m_beforeGroups
protected java.lang.String[] m_beforeGroups
-
m_afterGroups
protected java.lang.String[] m_afterGroups
-
m_currentInvocationCount
protected java.util.concurrent.atomic.AtomicInteger m_currentInvocationCount
-
-
Constructor Detail
-
BaseTestMethod
public BaseTestMethod(java.lang.String methodName, ConstructorOrMethod com, IAnnotationFinder annotationFinder, java.lang.Object instance)
-
-
Method Detail
-
isAlwaysRun
public boolean isAlwaysRun()
- Specified by:
isAlwaysRun
in interfaceITestNGMethod
- Returns:
- true if this method is alwaysRun=true
-
setAlwaysRun
protected void setAlwaysRun(boolean alwaysRun)
-
getRealClass
public java.lang.Class<?> getRealClass()
- Specified by:
getRealClass
in interfaceITestNGMethod
- 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
public ITestClass getTestClass()
- Specified by:
getTestClass
in interfaceITestNGMethod
-
setTestClass
public void setTestClass(ITestClass tc)
Sets the test class having this method. This is not necessarily the declaring class.- Specified by:
setTestClass
in interfaceITestNGMethod
- Parameters:
tc
- The test class having this method.
-
getMethodName
public java.lang.String getMethodName()
Returns the method name. This is needed for serialization because methods are not Serializable.- Specified by:
getMethodName
in interfaceITestNGMethod
- Returns:
- the method name.
-
getInstance
public java.lang.Object getInstance()
- Specified by:
getInstance
in interfaceITestNGMethod
-
getInstanceHashCodes
public long[] getInstanceHashCodes()
Needed for serialization.- Specified by:
getInstanceHashCodes
in interfaceITestNGMethod
-
getGroups
public java.lang.String[] getGroups()
- Specified by:
getGroups
in interfaceITestNGMethod
- Returns:
- the addition of groups defined on the class and on this method.
-
getGroupsDependedUpon
public java.lang.String[] getGroupsDependedUpon()
- Specified by:
getGroupsDependedUpon
in interfaceITestNGMethod
- Returns:
- The groups this method depends on, possibly added to the groups declared on the class.
-
getMethodsDependedUpon
public java.lang.String[] getMethodsDependedUpon()
- Specified by:
getMethodsDependedUpon
in interfaceITestNGMethod
- Returns:
- The methods this method depends on, possibly added to the methods declared on the class.
-
isTest
public boolean isTest()
- Specified by:
isTest
in interfaceITestNGMethod
- Returns:
- true if this method was annotated with @Test
-
isBeforeSuiteConfiguration
public boolean isBeforeSuiteConfiguration()
- Specified by:
isBeforeSuiteConfiguration
in interfaceITestNGMethod
- Returns:
- true if this method was annotated with @Configuration and beforeSuite = true
-
isAfterSuiteConfiguration
public boolean isAfterSuiteConfiguration()
- Specified by:
isAfterSuiteConfiguration
in interfaceITestNGMethod
- Returns:
- true if this method was annotated with @Configuration and afterSuite = true
-
isBeforeTestConfiguration
public boolean isBeforeTestConfiguration()
- Specified by:
isBeforeTestConfiguration
in interfaceITestNGMethod
- Returns:
- true if this method is a @BeforeTest (@Configuration beforeTest=true)
-
isAfterTestConfiguration
public boolean isAfterTestConfiguration()
- Specified by:
isAfterTestConfiguration
in interfaceITestNGMethod
- Returns:
- true if this method is an @AfterTest (@Configuration afterTest=true)
-
isBeforeGroupsConfiguration
public boolean isBeforeGroupsConfiguration()
- Specified by:
isBeforeGroupsConfiguration
in interfaceITestNGMethod
-
isAfterGroupsConfiguration
public boolean isAfterGroupsConfiguration()
- Specified by:
isAfterGroupsConfiguration
in interfaceITestNGMethod
-
isBeforeClassConfiguration
public boolean isBeforeClassConfiguration()
- Specified by:
isBeforeClassConfiguration
in interfaceITestNGMethod
- Returns:
- true if this method was annotated with @Configuration and beforeClassMethod = true
-
isAfterClassConfiguration
public boolean isAfterClassConfiguration()
- Specified by:
isAfterClassConfiguration
in interfaceITestNGMethod
- Returns:
- true if this method was annotated with @Configuration and beforeClassMethod = false
-
isBeforeMethodConfiguration
public boolean isBeforeMethodConfiguration()
- Specified by:
isBeforeMethodConfiguration
in interfaceITestNGMethod
- Returns:
- true if this method was annotated with @Configuration and beforeTestMethod = true
-
isAfterMethodConfiguration
public boolean isAfterMethodConfiguration()
- Specified by:
isAfterMethodConfiguration
in interfaceITestNGMethod
- Returns:
- true if this method was annotated with @Configuration and beforeTestMethod = false
-
getTimeOut
public long getTimeOut()
- Specified by:
getTimeOut
in interfaceITestNGMethod
- Returns:
- The timeout in milliseconds.
-
setTimeOut
public void setTimeOut(long timeOut)
- Specified by:
setTimeOut
in interfaceITestNGMethod
-
getInvocationCount
public int getInvocationCount()
- Specified by:
getInvocationCount
in interfaceITestNGMethod
- Returns:
- the number of times this method needs to be invoked.
-
setInvocationCount
public void setInvocationCount(int counter)
No-op.- Specified by:
setInvocationCount
in interfaceITestNGMethod
-
getSuccessPercentage
public int getSuccessPercentage()
Default value for successPercentage.- Specified by:
getSuccessPercentage
in interfaceITestNGMethod
- Returns:
- the success percentage for this method (between 0 and 100).
-
getId
public java.lang.String getId()
- Specified by:
getId
in interfaceITestNGMethod
- Returns:
- The id of the thread this method was run in.
-
setId
public void setId(java.lang.String id)
- Specified by:
setId
in interfaceITestNGMethod
-
getDate
public long getDate()
- Specified by:
getDate
in interfaceITestNGMethod
- Returns:
- Returns the date.
-
setDate
public void setDate(long date)
- Specified by:
setDate
in interfaceITestNGMethod
- Parameters:
date
- The date to set.
-
canRunFromClass
public boolean canRunFromClass(IClass testClass)
Returns if this ITestNGMethod can be invoked from within IClass.- Specified by:
canRunFromClass
in interfaceITestNGMethod
-
equals
public boolean equals(java.lang.Object obj)
Compares two BaseTestMethod using the test class then the associated Java Method.- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
This implementation returns the associated Java Method's hash code.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the associated Java Method's hash code.
-
initGroups
protected void initGroups(java.lang.Class<? extends ITestOrConfiguration> annotationClass)
-
initBeforeAfterGroups
protected void initBeforeAfterGroups(java.lang.Class<? extends ITestOrConfiguration> annotationClass, java.lang.String[] groups)
-
getAnnotationFinder
protected IAnnotationFinder getAnnotationFinder()
-
getIClass
protected IClass getIClass()
-
getSimpleName
public java.lang.String getSimpleName()
-
getSignature
protected java.lang.String getSignature()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getStringArray
protected java.lang.String[] getStringArray(java.lang.String[] methodArray, java.lang.String[] classArray)
-
setGroups
protected void setGroups(java.lang.String[] groups)
-
setGroupsDependedUpon
protected void setGroupsDependedUpon(java.lang.String[] groups, java.util.Collection<java.lang.String> xmlGroupDependencies)
-
setMethodsDependedUpon
protected void setMethodsDependedUpon(java.lang.String[] methods)
-
addMethodDependedUpon
public void addMethodDependedUpon(java.lang.String method)
- Specified by:
addMethodDependedUpon
in interfaceITestNGMethod
-
getMissingGroup
public java.lang.String getMissingGroup()
If a group was not found.- Specified by:
getMissingGroup
in interfaceITestNGMethod
-
setMissingGroup
public void setMissingGroup(java.lang.String group)
- Specified by:
setMissingGroup
in interfaceITestNGMethod
-
getThreadPoolSize
public int getThreadPoolSize()
- Specified by:
getThreadPoolSize
in interfaceITestNGMethod
- Returns:
- the number of threads to be used when invoking the method on parallel
-
setThreadPoolSize
public void setThreadPoolSize(int threadPoolSize)
No-op.- Specified by:
setThreadPoolSize
in interfaceITestNGMethod
-
setDescription
public void setDescription(java.lang.String description)
- Specified by:
setDescription
in interfaceITestNGMethod
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescription
in interfaceITestNGMethod
-
setEnabled
public void setEnabled(boolean enabled)
-
getEnabled
public boolean getEnabled()
- Specified by:
getEnabled
in interfaceITestNGMethod
-
getBeforeGroups
public java.lang.String[] getBeforeGroups()
Before and After groups- Specified by:
getBeforeGroups
in interfaceITestNGMethod
-
getAfterGroups
public java.lang.String[] getAfterGroups()
- Specified by:
getAfterGroups
in interfaceITestNGMethod
-
incrementCurrentInvocationCount
public void incrementCurrentInvocationCount()
- Specified by:
incrementCurrentInvocationCount
in interfaceITestNGMethod
-
getCurrentInvocationCount
public int getCurrentInvocationCount()
- Specified by:
getCurrentInvocationCount
in interfaceITestNGMethod
-
setParameterInvocationCount
public void setParameterInvocationCount(int n)
- Specified by:
setParameterInvocationCount
in interfaceITestNGMethod
-
getParameterInvocationCount
public int getParameterInvocationCount()
- Specified by:
getParameterInvocationCount
in interfaceITestNGMethod
-
setMoreInvocationChecker
public void setMoreInvocationChecker(java.util.concurrent.Callable<java.lang.Boolean> moreInvocationChecker)
- Specified by:
setMoreInvocationChecker
in interfaceITestNGMethod
-
hasMoreInvocation
public boolean hasMoreInvocation()
- Specified by:
hasMoreInvocation
in interfaceITestNGMethod
-
clone
public abstract ITestNGMethod clone()
- Specified by:
clone
in interfaceITestNGMethod
- Overrides:
clone
in classjava.lang.Object
-
getRetryAnalyzer
public IRetryAnalyzer getRetryAnalyzer()
- Specified by:
getRetryAnalyzer
in interfaceITestNGMethod
-
getRetryAnalyzer
public IRetryAnalyzer getRetryAnalyzer(ITestResult result)
- Specified by:
getRetryAnalyzer
in interfaceITestNGMethod
-
setRetryAnalyzer
public void setRetryAnalyzer(IRetryAnalyzer retryAnalyzer)
- Specified by:
setRetryAnalyzer
in interfaceITestNGMethod
-
setRetryAnalyzerClass
public void setRetryAnalyzerClass(java.lang.Class<? extends IRetryAnalyzer> clazz)
- Specified by:
setRetryAnalyzerClass
in interfaceITestNGMethod
-
getRetryAnalyzerClass
public java.lang.Class<? extends IRetryAnalyzer> getRetryAnalyzerClass()
- Specified by:
getRetryAnalyzerClass
in interfaceITestNGMethod
-
skipFailedInvocations
public boolean skipFailedInvocations()
- Specified by:
skipFailedInvocations
in interfaceITestNGMethod
-
setSkipFailedInvocations
public void setSkipFailedInvocations(boolean s)
- Specified by:
setSkipFailedInvocations
in interfaceITestNGMethod
-
setInvocationTimeOut
public void setInvocationTimeOut(long timeOut)
-
getInvocationTimeOut
public long getInvocationTimeOut()
Description copied from interface:ITestNGMethod
The time under which all invocationCount methods need to complete by.- Specified by:
getInvocationTimeOut
in interfaceITestNGMethod
-
ignoreMissingDependencies
public boolean ignoreMissingDependencies()
- Specified by:
ignoreMissingDependencies
in interfaceITestNGMethod
-
setIgnoreMissingDependencies
public void setIgnoreMissingDependencies(boolean i)
- Specified by:
setIgnoreMissingDependencies
in interfaceITestNGMethod
-
getInvocationNumbers
public java.util.List<java.lang.Integer> getInvocationNumbers()
Description copied from interface:ITestNGMethod
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 thetag. - Specified by:
getInvocationNumbers
in interfaceITestNGMethod
-
setInvocationNumbers
public void setInvocationNumbers(java.util.List<java.lang.Integer> numbers)
- Specified by:
setInvocationNumbers
in interfaceITestNGMethod
-
getFailedInvocationNumbers
public java.util.List<java.lang.Integer> getFailedInvocationNumbers()
- Specified by:
getFailedInvocationNumbers
in interfaceITestNGMethod
-
addFailedInvocationNumber
public void addFailedInvocationNumber(int number)
Description copied from interface:ITestNGMethod
The list of invocation numbers that failed, which is only applicable for methods that have a data provider.- Specified by:
addFailedInvocationNumber
in interfaceITestNGMethod
-
getPriority
public int getPriority()
Description copied from interface:ITestNGMethod
The scheduling priority. Lower priorities get scheduled first.- Specified by:
getPriority
in interfaceITestNGMethod
-
setPriority
public void setPriority(int priority)
- Specified by:
setPriority
in interfaceITestNGMethod
-
getInterceptedPriority
public int getInterceptedPriority()
- Specified by:
getInterceptedPriority
in interfaceITestNGMethod
-
setInterceptedPriority
public void setInterceptedPriority(int priority)
- Specified by:
setInterceptedPriority
in interfaceITestNGMethod
-
getXmlTest
public XmlTest getXmlTest()
- Specified by:
getXmlTest
in interfaceITestNGMethod
- Returns:
- the XmlTest this method belongs to.
-
setXmlTest
public void setXmlTest(XmlTest xmlTest)
-
getConstructorOrMethod
public ConstructorOrMethod getConstructorOrMethod()
- Specified by:
getConstructorOrMethod
in interfaceITestNGMethod
-
findMethodParameters
public java.util.Map<java.lang.String,java.lang.String> findMethodParameters(XmlTest test)
- Specified by:
findMethodParameters
in interfaceITestNGMethod
- Parameters:
test
- - TheXmlTest
object.- Returns:
- the parameters found in the include tag, if any
-
getQualifiedName
public java.lang.String getQualifiedName()
Description copied from interface:ITestNGMethod
getRealClass().getName() + "." + getMethodName()- Specified by:
getQualifiedName
in interfaceITestNGMethod
- Returns:
- qualified name for this method
-
getFactoryMethodParamsInfo
public IParameterInfo getFactoryMethodParamsInfo()
- Specified by:
getFactoryMethodParamsInfo
in interfaceITestNGMethod
- Returns:
- - A
IParameterInfo
object that represents details about the parameters associated with the factory method.
-
-