Package org.testng.internal
Class BaseTestMethod
java.lang.Object
org.testng.internal.BaseTestMethod
- All Implemented Interfaces:
Cloneable,IInvocationStatus,ITestNGMethod
- Direct Known Subclasses:
ConfigurationMethod,FactoryMethod,JUnitTestMethod,TestNGMethod
Superclass to represent both @Test and @Configuration methods.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String[]protected final IAnnotationFinderprotected String[]protected AtomicIntegerprotected longprotected String[]protected String[]protected Stringprotected final ConstructorOrMethodprotected final Class<?>protected String[]protected ITestClassThe test class on which the test method was found. -
Constructor Summary
ConstructorsConstructorDescriptionBaseTestMethod(String methodName, ConstructorOrMethod com, IAnnotationFinder annotationFinder, Object instance) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFailedInvocationNumber(int number) The list of invocation numbers that failed, which is only applicable for methods that have a data provider.voidaddMethodDependedUpon(String method) booleancanRunFromClass(IClass testClass) abstract ITestNGMethodclone()booleanCompares two BaseTestMethod using the test class then the associated Java Method.findMethodParameters(XmlTest test) String[]protected IAnnotationFinderString[]intlonggetDate()booleanString[]String[]protected IClassgetId()long[]Needed for serialization.intintWhich invocation numbers of this method should be used (only applicable if it uses a data provider).longlongReturns the method name.String[]intClass<?>[]intThe scheduling priority.getRealClass().getName() + "." + getMethodName()Class<?>getRetryAnalyzer(ITestResult result) Class<? extends IRetryAnalyzer>protected Stringprotected String[]getStringArray(String[] methodArray, String[] classArray) intDefault value for successPercentage.intlonginthashCode()This implementation returns the associated Java Method's hash code.booleanbooleanvoidprotected voidinitBeforeAfterGroups(Class<? extends ITestOrConfiguration> annotationClass, String[] groups) protected voidinitGroups(Class<? extends ITestOrConfiguration> annotationClass) booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanisTest()protected voidsetAlwaysRun(boolean alwaysRun) voidsetDate(long date) voidsetDescription(String description) voidsetEnabled(boolean enabled) protected voidprotected voidsetGroupsDependedUpon(String[] groups, Collection<String> xmlGroupDependencies) voidvoidsetIgnoreMissingDependencies(boolean i) voidsetInterceptedPriority(int priority) voidsetInvocationCount(int counter) No-op.voidsetInvocationNumbers(List<Integer> numbers) voidsetInvocationTimeOut(long timeOut) voidsetInvokedAt(long date) protected voidsetMethodsDependedUpon(String[] methods) voidsetMissingGroup(String group) voidsetMoreInvocationChecker(Callable<Boolean> moreInvocationChecker) voidsetParameterInvocationCount(int n) voidsetPriority(int priority) voidsetRetryAnalyzerClass(Class<? extends IRetryAnalyzer> clazz) voidsetSkipFailedInvocations(boolean s) voidSets the test class having this method.voidsetThreadPoolSize(int threadPoolSize) No-op.voidsetTimeOut(long timeOut) voidsetXmlTest(XmlTest xmlTest) booleantoString()Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.testng.ITestNGMethod
getAttributes, getDataProviderMethod, hasAfterGroupsConfiguration, hasBeforeGroupsConfiguration, isDataDriven
-
Field Details
-
m_testClass
The test class on which the test method was found. Note that this is not necessarily the declaring class. -
m_methodClass
-
m_method
-
m_id
-
m_date
protected long m_date -
m_annotationFinder
-
m_groups
-
m_groupsDependedUpon
-
m_methodsDependedUpon
-
m_beforeGroups
-
m_afterGroups
-
m_currentInvocationCount
-
-
Constructor Details
-
BaseTestMethod
public BaseTestMethod(String methodName, ConstructorOrMethod com, IAnnotationFinder annotationFinder, Object instance)
-
-
Method Details
-
isAlwaysRun
public boolean isAlwaysRun()- Specified by:
isAlwaysRunin interfaceITestNGMethod- Returns:
- true if this method is alwaysRun=true
-
setAlwaysRun
protected void setAlwaysRun(boolean alwaysRun) -
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
- Specified by:
getTestClassin interfaceITestNGMethod
-
setTestClass
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
Returns the method name. This is needed for serialization because methods are not Serializable.- Specified by:
getMethodNamein interfaceITestNGMethod- Returns:
- the method name.
-
getInstance
- Specified by:
getInstancein interfaceITestNGMethod
-
getInstanceHashCodes
public long[] getInstanceHashCodes()Needed for serialization.- Specified by:
getInstanceHashCodesin interfaceITestNGMethod- Returns:
- The hashcode of instances
-
getGroups
- Specified by:
getGroupsin interfaceITestNGMethod- Returns:
- the addition of groups defined on the class and on this method.
-
getGroupsDependedUpon
- Specified by:
getGroupsDependedUponin interfaceITestNGMethod- Returns:
- The groups this method depends on, possibly added to the groups declared on the class.
-
getMethodsDependedUpon
- Specified by:
getMethodsDependedUponin interfaceITestNGMethod- Returns:
- The methods this method depends on, possibly added to the methods declared on the class.
-
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
- Specified by:
getIdin interfaceITestNGMethod- Returns:
- The id of the thread this method was run in.
-
setId
- 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
- Specified by:
canRunFromClassin interfaceITestNGMethod- Parameters:
testClass- The test class- Returns:
- true if this ITestNGMethod can be invoked from within IClass.
-
equals
Compares two BaseTestMethod using the test class then the associated Java Method. -
hashCode
public int hashCode()This implementation returns the associated Java Method's hash code. -
initGroups
-
initBeforeAfterGroups
protected void initBeforeAfterGroups(Class<? extends ITestOrConfiguration> annotationClass, String[] groups) -
getAnnotationFinder
-
getIClass
-
getSimpleName
-
getSignature
-
toString
-
getStringArray
-
setGroups
-
setGroupsDependedUpon
-
setMethodsDependedUpon
-
addMethodDependedUpon
- Specified by:
addMethodDependedUponin interfaceITestNGMethod
-
getMissingGroup
- Specified by:
getMissingGroupin interfaceITestNGMethod- Returns:
- If a group was not found.
-
setMissingGroup
- 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
- Specified by:
setDescriptionin interfaceITestNGMethod
-
getDescription
- Specified by:
getDescriptionin interfaceITestNGMethod
-
setEnabled
public void setEnabled(boolean enabled) -
getEnabled
public boolean getEnabled()- Specified by:
getEnabledin interfaceITestNGMethod
-
getBeforeGroups
- Specified by:
getBeforeGroupsin interfaceITestNGMethod
-
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
- Specified by:
setMoreInvocationCheckerin interfaceITestNGMethod
-
hasMoreInvocation
public boolean hasMoreInvocation()- Specified by:
hasMoreInvocationin interfaceITestNGMethod
-
clone
- Specified by:
clonein interfaceITestNGMethod- Overrides:
clonein classObject
-
getRetryAnalyzer
- Specified by:
getRetryAnalyzerin interfaceITestNGMethod
-
setRetryAnalyzerClass
- Specified by:
setRetryAnalyzerClassin interfaceITestNGMethod
-
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
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
- Specified by:
setInvocationNumbersin interfaceITestNGMethod
-
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
- Specified by:
getXmlTestin interfaceITestNGMethod- Returns:
- the XmlTest this method belongs to.
-
setXmlTest
-
getConstructorOrMethod
- Specified by:
getConstructorOrMethodin interfaceITestNGMethod
-
getParameterTypes
- Specified by:
getParameterTypesin interfaceITestNGMethod
-
findMethodParameters
- Specified by:
findMethodParametersin interfaceITestNGMethod- Parameters:
test- - TheXmlTestobject.- Returns:
- the parameters found in the include tag, if any
-
getQualifiedName
Description copied from interface:ITestNGMethodgetRealClass().getName() + "." + getMethodName()- Specified by:
getQualifiedNamein interfaceITestNGMethod- Returns:
- qualified name for this method
-
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.
-