Package org.testng.internal
Class BaseTestMethod
- java.lang.Object
-
- org.testng.internal.BaseTestMethod
-
- All Implemented Interfaces:
java.lang.Cloneable,IInstanceIdentity,IInvocationStatus,ITestNGMethod
- Direct Known Subclasses:
ConfigurationMethod,FactoryMethod,TestNGMethod
public abstract class BaseTestMethod extends java.lang.Object implements ITestNGMethod, IInvocationStatus, IInstanceIdentity
Superclass to represent both @Test and @Configuration methods.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String[]m_afterGroupsprotected IAnnotationFinderm_annotationFinderprotected java.lang.String[]m_beforeGroupsprotected java.util.concurrent.atomic.AtomicIntegerm_currentInvocationCountprotected longm_dateprotected java.lang.String[]m_groupsprotected java.lang.String[]m_groupsDependedUponprotected java.lang.Stringm_idprotected ConstructorOrMethodm_methodprotected java.lang.Class<?>m_methodClassprotected java.lang.String[]m_methodsDependedUponprotected ITestObjectFactorym_objectFactoryprotected ITestClassm_testClassThe test class on which the test method was found.
-
Constructor Summary
Constructors Constructor Description BaseTestMethod(ITestObjectFactory objectFactory, java.lang.String methodName, ConstructorOrMethod com, IAnnotationFinder annotationFinder, IObject.IdentifiableObject instance)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddFailedInvocationNumber(int number)The list of invocation numbers that failed, which is only applicable for methods that have a data provider.voidaddMethodDependedUpon(java.lang.String method)booleancanRunFromClass(IClass testClass)abstract ITestNGMethodclone()java.util.Set<ITestNGMethod>downstreamDependencies()booleanequals(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 IAnnotationFindergetAnnotationFinder()java.lang.String[]getBeforeGroups()ConstructorOrMethodgetConstructorOrMethod()intgetCurrentInvocationCount()longgetDate()java.lang.StringgetDescription()booleangetEnabled()IParameterInfogetFactoryMethodParamsInfo()java.util.List<java.lang.Integer>getFailedInvocationNumbers()java.lang.String[]getGroups()java.lang.String[]getGroupsDependedUpon()java.lang.StringgetId()java.lang.ObjectgetInstance()long[]getInstanceHashCodes()Needed for serialization.java.util.UUIDgetInstanceId()intgetInterceptedPriority()intgetInvocationCount()java.util.List<java.lang.Integer>getInvocationNumbers()Which invocation numbers of this method should be used (only applicable if it uses a data provider).longgetInvocationTime()longgetInvocationTimeOut()java.lang.StringgetMethodName()Returns the method name.java.lang.String[]getMethodsDependedUpon()java.lang.StringgetMissingGroup()intgetParameterInvocationCount()java.lang.Class<?>[]getParameterTypes()intgetPriority()The scheduling priority.java.lang.StringgetQualifiedName()getRealClass().getName() + "." + getMethodName()java.lang.Class<?>getRealClass()IRetryAnalyzergetRetryAnalyzer(ITestResult result)java.lang.Class<? extends IRetryAnalyzer>getRetryAnalyzerClass()protected java.lang.StringgetSignature()java.lang.StringgetSimpleName()protected java.lang.String[]getStringArray(java.lang.String[] methodArray, java.lang.String[] classArray)intgetSuccessPercentage()Default value for successPercentage.ITestClassgetTestClass()intgetThreadPoolSize()longgetTimeOut()XmlTestgetXmlTest()inthashCode()This implementation returns the associated Java Method's hash code.booleanhasMoreInvocation()booleanignoreMissingDependencies()voidincrementCurrentInvocationCount()protected voidinitBeforeAfterGroups(java.lang.Class<? extends ITestOrConfiguration> annotationClass, java.lang.String[] groups)protected voidinitGroups(java.lang.Class<? extends ITestOrConfiguration> annotationClass)booleanisAfterClassConfiguration()booleanisAfterGroupsConfiguration()booleanisAfterMethodConfiguration()booleanisAfterSuiteConfiguration()booleanisAfterTestConfiguration()booleanisAlwaysRun()booleanisBeforeClassConfiguration()booleanisBeforeGroupsConfiguration()booleanisBeforeMethodConfiguration()booleanisBeforeSuiteConfiguration()booleanisBeforeTestConfiguration()booleanisTest()protected voidsetAlwaysRun(boolean alwaysRun)voidsetDate(long date)voidsetDescription(java.lang.String description)voidsetDownstreamDependencies(java.util.Set<ITestNGMethod> methods)voidsetEnabled(boolean enabled)protected voidsetGroups(java.lang.String[] groups)protected voidsetGroupsDependedUpon(java.lang.String[] groups, java.util.Collection<java.lang.String> xmlGroupDependencies)voidsetId(java.lang.String id)voidsetIgnoreMissingDependencies(boolean i)voidsetInterceptedPriority(int priority)voidsetInvocationCount(int counter)No-op.voidsetInvocationNumbers(java.util.List<java.lang.Integer> numbers)voidsetInvocationTimeOut(long timeOut)voidsetInvokedAt(long date)protected voidsetMethodsDependedUpon(java.lang.String[] methods)voidsetMissingGroup(java.lang.String group)voidsetMoreInvocationChecker(java.util.concurrent.Callable<java.lang.Boolean> moreInvocationChecker)voidsetParameterInvocationCount(int n)voidsetPriority(int priority)voidsetRetryAnalyzerClass(java.lang.Class<? extends IRetryAnalyzer> clazz)voidsetSkipFailedInvocations(boolean s)voidsetTestClass(ITestClass tc)Sets the test class having this method.voidsetThreadPoolSize(int threadPoolSize)No-op.voidsetTimeOut(long timeOut)voidsetUpstreamDependencies(java.util.Set<ITestNGMethod> methods)voidsetXmlTest(XmlTest xmlTest)booleanskipFailedInvocations()java.lang.StringtoString()java.util.Set<ITestNGMethod>upstreamDependencies()-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.testng.ITestNGMethod
getAttributes, getDataProviderMethod, hasAfterGroupsConfiguration, hasBeforeGroupsConfiguration, isDataDriven, isIgnoreFailure
-
-
-
-
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
-
m_objectFactory
protected final ITestObjectFactory m_objectFactory
-
-
Constructor Detail
-
BaseTestMethod
public BaseTestMethod(ITestObjectFactory objectFactory, java.lang.String methodName, ConstructorOrMethod com, IAnnotationFinder annotationFinder, IObject.IdentifiableObject instance)
-
-
Method Detail
-
isAlwaysRun
public boolean isAlwaysRun()
- Specified by:
isAlwaysRunin interfaceITestNGMethod- Returns:
- true if this method is alwaysRun=true
-
setAlwaysRun
protected void setAlwaysRun(boolean alwaysRun)
-
getRealClass
public java.lang.Class<?> getRealClass()
- Specified by:
getRealClassin 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:
getTestClassin interfaceITestNGMethod
-
setTestClass
public void setTestClass(ITestClass tc)
Sets the test class having this method. This is not necessarily the declaring class.- Specified by:
setTestClassin 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:
getMethodNamein interfaceITestNGMethod- Returns:
- the method name.
-
getInstance
public java.lang.Object getInstance()
- Specified by:
getInstancein interfaceITestNGMethod
-
getInstanceId
public java.util.UUID getInstanceId()
- Specified by:
getInstanceIdin interfaceIInstanceIdentity- Returns:
- - A
that represents a unique id which is associated with every test class object.UUID
-
getInstanceHashCodes
public long[] getInstanceHashCodes()
Needed for serialization.- Specified by:
getInstanceHashCodesin interfaceITestNGMethod- Returns:
- The hashcode of instances
-
getGroups
public java.lang.String[] getGroups()
- Specified by:
getGroupsin interfaceITestNGMethod- Returns:
- the addition of groups defined on the class and on this method.
-
getGroupsDependedUpon
public java.lang.String[] getGroupsDependedUpon()
- Specified by:
getGroupsDependedUponin 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:
getMethodsDependedUponin interfaceITestNGMethod- Returns:
- The methods this method depends on, possibly added to the methods declared on the class.
-
downstreamDependencies
public java.util.Set<ITestNGMethod> downstreamDependencies()
- Specified by:
downstreamDependenciesin interfaceITestNGMethod- 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
public java.util.Set<ITestNGMethod> upstreamDependencies()
- Specified by:
upstreamDependenciesin interfaceITestNGMethod- 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.
-
setDownstreamDependencies
public void setDownstreamDependencies(java.util.Set<ITestNGMethod> methods)
-
setUpstreamDependencies
public void setUpstreamDependencies(java.util.Set<ITestNGMethod> methods)
-
isTest
public boolean isTest()
- Specified by:
isTestin interfaceITestNGMethod- Returns:
- true if this method was annotated with @Test
-
isBeforeSuiteConfiguration
public boolean isBeforeSuiteConfiguration()
- Specified by:
isBeforeSuiteConfigurationin interfaceITestNGMethod- Returns:
- true if this method was annotated with @Configuration and beforeSuite = true
-
isAfterSuiteConfiguration
public boolean isAfterSuiteConfiguration()
- Specified by:
isAfterSuiteConfigurationin interfaceITestNGMethod- Returns:
- true if this method was annotated with @Configuration and afterSuite = true
-
isBeforeTestConfiguration
public boolean isBeforeTestConfiguration()
- Specified by:
isBeforeTestConfigurationin interfaceITestNGMethod- Returns:
trueif this method is a @BeforeTest (@Configuration beforeTest=true)
-
isAfterTestConfiguration
public boolean isAfterTestConfiguration()
- Specified by:
isAfterTestConfigurationin interfaceITestNGMethod- Returns:
trueif this method is an @AfterTest (@Configuration afterTest=true)
-
isBeforeGroupsConfiguration
public boolean isBeforeGroupsConfiguration()
- Specified by:
isBeforeGroupsConfigurationin interfaceITestNGMethod
-
isAfterGroupsConfiguration
public boolean isAfterGroupsConfiguration()
- Specified by:
isAfterGroupsConfigurationin interfaceITestNGMethod
-
isBeforeClassConfiguration
public boolean isBeforeClassConfiguration()
- Specified by:
isBeforeClassConfigurationin interfaceITestNGMethod- Returns:
- true if this method was annotated with @Configuration and beforeClassMethod = true
-
isAfterClassConfiguration
public boolean isAfterClassConfiguration()
- Specified by:
isAfterClassConfigurationin interfaceITestNGMethod- Returns:
- true if this method was annotated with @Configuration and beforeClassMethod = false
-
isBeforeMethodConfiguration
public boolean isBeforeMethodConfiguration()
- Specified by:
isBeforeMethodConfigurationin interfaceITestNGMethod- Returns:
- true if this method was annotated with @Configuration and beforeTestMethod = true
-
isAfterMethodConfiguration
public boolean isAfterMethodConfiguration()
- Specified by:
isAfterMethodConfigurationin interfaceITestNGMethod- Returns:
- true if this method was annotated with @Configuration and beforeTestMethod = false
-
getTimeOut
public long getTimeOut()
- Specified by:
getTimeOutin interfaceITestNGMethod- Returns:
- The timeout in milliseconds.
-
setTimeOut
public void setTimeOut(long timeOut)
- Specified by:
setTimeOutin interfaceITestNGMethod
-
getInvocationCount
public int getInvocationCount()
- Specified by:
getInvocationCountin interfaceITestNGMethod- Returns:
- the number of times this method needs to be invoked.
-
setInvocationCount
public void setInvocationCount(int counter)
No-op.- Specified by:
setInvocationCountin interfaceITestNGMethod
-
getSuccessPercentage
public int getSuccessPercentage()
Default value for successPercentage.- Specified by:
getSuccessPercentagein interfaceITestNGMethod- Returns:
- the success percentage for this method (between 0 and 100).
-
getId
public java.lang.String getId()
- Specified by:
getIdin interfaceITestNGMethod- Returns:
- The id of the thread this method was run in.
-
setId
public void setId(java.lang.String id)
- Specified by:
setIdin interfaceITestNGMethod
-
getDate
public long getDate()
- Specified by:
getDatein interfaceITestNGMethod- Returns:
- Returns the date.
-
setDate
public void setDate(long date)
- Specified by:
setDatein interfaceITestNGMethod- Parameters:
date- The date to set.
-
canRunFromClass
public boolean canRunFromClass(IClass testClass)
- Specified by:
canRunFromClassin interfaceITestNGMethod- Parameters:
testClass- The test class- Returns:
- true if this ITestNGMethod can be invoked from within IClass.
-
equals
public boolean equals(java.lang.Object obj)
Compares two BaseTestMethod using the test class then the associated Java Method.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
This implementation returns the associated Java Method's hash code.- Overrides:
hashCodein 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()
-
getSimpleName
public java.lang.String getSimpleName()
-
getSignature
protected java.lang.String getSignature()
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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:
addMethodDependedUponin interfaceITestNGMethod
-
getMissingGroup
public java.lang.String getMissingGroup()
- Specified by:
getMissingGroupin interfaceITestNGMethod- Returns:
- If a group was not found.
-
setMissingGroup
public void setMissingGroup(java.lang.String group)
- Specified by:
setMissingGroupin interfaceITestNGMethod
-
getThreadPoolSize
public int getThreadPoolSize()
- Specified by:
getThreadPoolSizein 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:
setThreadPoolSizein interfaceITestNGMethod
-
setDescription
public void setDescription(java.lang.String description)
- Specified by:
setDescriptionin interfaceITestNGMethod
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescriptionin interfaceITestNGMethod
-
setEnabled
public void setEnabled(boolean enabled)
-
getEnabled
public boolean getEnabled()
- Specified by:
getEnabledin interfaceITestNGMethod
-
getBeforeGroups
public java.lang.String[] getBeforeGroups()
- Specified by:
getBeforeGroupsin interfaceITestNGMethod
-
getAfterGroups
public java.lang.String[] getAfterGroups()
- Specified by:
getAfterGroupsin interfaceITestNGMethod
-
incrementCurrentInvocationCount
public void incrementCurrentInvocationCount()
- Specified by:
incrementCurrentInvocationCountin interfaceITestNGMethod
-
getCurrentInvocationCount
public int getCurrentInvocationCount()
- Specified by:
getCurrentInvocationCountin interfaceITestNGMethod
-
setParameterInvocationCount
public void setParameterInvocationCount(int n)
- Specified by:
setParameterInvocationCountin interfaceITestNGMethod
-
getParameterInvocationCount
public int getParameterInvocationCount()
- Specified by:
getParameterInvocationCountin interfaceITestNGMethod
-
setMoreInvocationChecker
public void setMoreInvocationChecker(java.util.concurrent.Callable<java.lang.Boolean> moreInvocationChecker)
- Specified by:
setMoreInvocationCheckerin interfaceITestNGMethod
-
hasMoreInvocation
public boolean hasMoreInvocation()
- Specified by:
hasMoreInvocationin interfaceITestNGMethod
-
clone
public abstract ITestNGMethod clone()
- Specified by:
clonein interfaceITestNGMethod- Overrides:
clonein classjava.lang.Object
-
getRetryAnalyzer
public IRetryAnalyzer getRetryAnalyzer(ITestResult result)
- Specified by:
getRetryAnalyzerin interfaceITestNGMethod
-
setRetryAnalyzerClass
public void setRetryAnalyzerClass(java.lang.Class<? extends IRetryAnalyzer> clazz)
- Specified by:
setRetryAnalyzerClassin interfaceITestNGMethod
-
getRetryAnalyzerClass
public java.lang.Class<? extends IRetryAnalyzer> getRetryAnalyzerClass()
- Specified by:
getRetryAnalyzerClassin interfaceITestNGMethod
-
skipFailedInvocations
public boolean skipFailedInvocations()
- Specified by:
skipFailedInvocationsin interfaceITestNGMethod
-
setSkipFailedInvocations
public void setSkipFailedInvocations(boolean s)
- Specified by:
setSkipFailedInvocationsin interfaceITestNGMethod
-
setInvocationTimeOut
public void setInvocationTimeOut(long timeOut)
-
getInvocationTimeOut
public long getInvocationTimeOut()
- Specified by:
getInvocationTimeOutin interfaceITestNGMethod- Returns:
- The time under which all invocationCount methods need to complete by.
-
ignoreMissingDependencies
public boolean ignoreMissingDependencies()
- Specified by:
ignoreMissingDependenciesin interfaceITestNGMethod
-
setIgnoreMissingDependencies
public void setIgnoreMissingDependencies(boolean i)
- Specified by:
setIgnoreMissingDependenciesin interfaceITestNGMethod
-
getInvocationNumbers
public java.util.List<java.lang.Integer> getInvocationNumbers()
Description copied from interface:ITestNGMethodWhich 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.- Specified by:
getInvocationNumbersin interfaceITestNGMethod- Returns:
- The list of invocation numbers
-
setInvocationNumbers
public void setInvocationNumbers(java.util.List<java.lang.Integer> numbers)
- Specified by:
setInvocationNumbersin interfaceITestNGMethod
-
getFailedInvocationNumbers
public java.util.List<java.lang.Integer> getFailedInvocationNumbers()
- Specified by:
getFailedInvocationNumbersin interfaceITestNGMethod
-
addFailedInvocationNumber
public void addFailedInvocationNumber(int number)
Description copied from interface:ITestNGMethodThe list of invocation numbers that failed, which is only applicable for methods that have a data provider.- Specified by:
addFailedInvocationNumberin interfaceITestNGMethod- Parameters:
number- The invocation number that failed
-
getPriority
public int getPriority()
Description copied from interface:ITestNGMethodThe scheduling priority. Lower priorities get scheduled first.- Specified by:
getPriorityin interfaceITestNGMethod- Returns:
- The priority value
-
setPriority
public void setPriority(int priority)
- Specified by:
setPriorityin interfaceITestNGMethod
-
getInterceptedPriority
public int getInterceptedPriority()
- Specified by:
getInterceptedPriorityin interfaceITestNGMethod
-
setInterceptedPriority
public void setInterceptedPriority(int priority)
- Specified by:
setInterceptedPriorityin interfaceITestNGMethod
-
getXmlTest
public XmlTest getXmlTest()
- Specified by:
getXmlTestin interfaceITestNGMethod- Returns:
- the XmlTest this method belongs to.
-
setXmlTest
public void setXmlTest(XmlTest xmlTest)
-
getConstructorOrMethod
public ConstructorOrMethod getConstructorOrMethod()
- Specified by:
getConstructorOrMethodin interfaceITestNGMethod
-
getParameterTypes
public java.lang.Class<?>[] getParameterTypes()
- Specified by:
getParameterTypesin interfaceITestNGMethod
-
findMethodParameters
public java.util.Map<java.lang.String,java.lang.String> findMethodParameters(XmlTest test)
- Specified by:
findMethodParametersin interfaceITestNGMethod- Parameters:
test- - TheXmlTestobject.- Returns:
- the parameters found in the include tag, if any
-
getQualifiedName
public java.lang.String getQualifiedName()
Description copied from interface:ITestNGMethodgetRealClass().getName() + "." + getMethodName()- Specified by:
getQualifiedNamein interfaceITestNGMethod- Returns:
- qualified name for this method
-
getFactoryMethodParamsInfo
public IParameterInfo getFactoryMethodParamsInfo()
- Specified by:
getFactoryMethodParamsInfoin interfaceITestNGMethod- Returns:
- - A
IParameterInfoobject that represents details about the parameters associated with the factory method.
-
setInvokedAt
public void setInvokedAt(long date)
- Specified by:
setInvokedAtin interfaceIInvocationStatus- Parameters:
date- - The timestamp at which a method was invoked.
-
getInvocationTime
public long getInvocationTime()
- Specified by:
getInvocationTimein interfaceIInvocationStatus- Returns:
- - The timestamp at which a method got invoked.
-
-