org.testng.internal
Class BaseTestMethod

java.lang.Object
  extended by org.testng.internal.BaseTestMethod
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, ITestNGMethod
Direct Known Subclasses:
ConfigurationMethod, FactoryMethod, TestNGMethod

public abstract class BaseTestMethod
extends java.lang.Object
implements ITestNGMethod

Superclass to represent both @Test and @Configuration methods.

See Also:
Serialized Form

Field Summary
static java.util.Comparator<?> DATE_COMPARATOR
          Compares two ITestNGMethod by date.
protected  java.lang.String[] m_afterGroups
           
protected  IAnnotationFinder m_annotationFinder
           
protected  java.lang.String[] m_beforeGroups
           
protected  IAtomicInteger 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  java.lang.reflect.Method 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
BaseTestMethod(java.lang.reflect.Method method, IAnnotationFinder annotationFinder)
          Constructs a BaseTestMethod TODO cquezel JavaDoc.
 
Method Summary
 void addMethodDependedUpon(java.lang.String method)
          
 boolean canRunFromClass(IClass testClass)
          Returns if this ITestNGMethod can be invoked from within IClass.
abstract  ITestNGMethod clone()
           
 int compareTo(java.lang.Object o)
          TODO cquezel JavaDoc.
 boolean equals(java.lang.Object obj)
           Compares two BaseTestMethod using the test class then the associated Java Method.
 java.lang.String[] getAfterGroups()
          
protected  IAnnotationFinder getAnnotationFinder()
          TODO cquezel JavaDoc.
 java.lang.String[] getBeforeGroups()
          Before and After groups
 int getCurrentInvocationCount()
           
 long getDate()
          
 java.lang.String getDescription()
          
 java.lang.String[] getGroups()
          
 java.lang.String[] getGroupsDependedUpon()
          
protected  IClass getIClass()
          TODO cquezel JavaDoc.
 java.lang.String getId()
          
 long[] getInstanceHashCodes()
          Needed for serialization.
 java.lang.Object[] getInstances()
          
 int getInvocationCount()
          
 java.lang.reflect.Method getMethod()
          Returns the corresponding Java test method.
 java.lang.String getMethodName()
          Returns the method name.
 java.lang.String[] getMethodsDependedUpon()
          
 java.lang.String getMissingGroup()
          If a group was not found.
 int getParameterInvocationCount()
           
 java.lang.Class<?> getRealClass()
          
 IRetryAnalyzer getRetryAnalyzer()
           
protected  java.lang.String getSignature()
          TODO cquezel JavaDoc.
protected  java.lang.String[] getStringArray(java.lang.String[] methodArray, java.lang.String[] classArray)
          TODO cquezel JavaDoc.
 int getSuccessPercentage()
           Default value for successPercentage.
 ITestClass getTestClass()
          
 int getThreadPoolSize()
          
 long getTimeOut()
          
 int hashCode()
           This implementation returns the associated Java Method's hash code.
 void incrementCurrentInvocationCount()
           
protected  void initGroups(java.lang.Class<?> annotationClass)
          TODO cquezel JavaDoc.
 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)
          TODO cquezel JavaDoc.
 void setDate(long date)
          
 void setDescription(java.lang.String description)
          TODO cquezel JavaDoc.
protected  void setGroups(java.lang.String[] groups)
           
protected  void setGroupsDependedUpon(java.lang.String[] groups)
           
 void setId(java.lang.String id)
          
 void setInvocationCount(int counter)
          No-op.
protected  void setMethodsDependedUpon(java.lang.String[] methods)
           
 void setMissingGroup(java.lang.String group)
          
 void setParameterInvocationCount(int n)
           
 void setRetryAnalyzer(IRetryAnalyzer retryAnalyzer)
           
 void setSkipFailedInvocations(boolean s)
           
 void setTestClass(ITestClass tc)
          Sets the test class having this method.
 void setThreadPoolSize(int threadPoolSize)
          No-op.
 boolean skipFailedInvocations()
           
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

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 transient java.lang.Class<?> m_methodClass

m_method

protected final transient java.lang.reflect.Method m_method

m_id

protected java.lang.String m_id

m_date

protected long m_date

m_annotationFinder

protected final transient 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 IAtomicInteger m_currentInvocationCount

DATE_COMPARATOR

public static final java.util.Comparator<?> DATE_COMPARATOR
Compares two ITestNGMethod by date.

Constructor Detail

BaseTestMethod

public BaseTestMethod(java.lang.reflect.Method method,
                      IAnnotationFinder annotationFinder)
Constructs a BaseTestMethod TODO cquezel JavaDoc.

Parameters:
method -
annotationFinder -
Method Detail

isAlwaysRun

public boolean isAlwaysRun()

Specified by:
isAlwaysRun in interface ITestNGMethod
Returns:
true if this method is alwaysRun=true

setAlwaysRun

protected void setAlwaysRun(boolean alwaysRun)
TODO cquezel JavaDoc.

Parameters:
alwaysRun -

getRealClass

public java.lang.Class<?> getRealClass()

Specified by:
getRealClass in interface ITestNGMethod
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 interface ITestNGMethod

setTestClass

public void setTestClass(ITestClass tc)
Sets the test class having this method. This is not necessarily the declaring class.

Specified by:
setTestClass in interface ITestNGMethod
Parameters:
tc - The test class having this method.

compareTo

public int compareTo(java.lang.Object o)
TODO cquezel JavaDoc.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o -
Returns:

getMethod

public java.lang.reflect.Method getMethod()
Returns the corresponding Java test method.

Specified by:
getMethod in interface ITestNGMethod
Returns:
the corresponding Java test 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 interface ITestNGMethod
Returns:
the method name.

getInstances

public java.lang.Object[] getInstances()

Specified by:
getInstances in interface ITestNGMethod
Returns:
All the instances the methods will be invoked upon. This will typically be an array of one object in the absence of an @Factory annotation.

getInstanceHashCodes

public long[] getInstanceHashCodes()
Needed for serialization.

Specified by:
getInstanceHashCodes in interface ITestNGMethod

getGroups

public java.lang.String[] getGroups()

Specified by:
getGroups in interface ITestNGMethod
Returns:
the addition of groups defined on the class and on this method.

getGroupsDependedUpon

public java.lang.String[] getGroupsDependedUpon()

Specified by:
getGroupsDependedUpon in interface ITestNGMethod
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 interface ITestNGMethod
Returns:
The methods this method depends on, possibly added to the methods declared on the class.

isTest

public boolean isTest()

Specified by:
isTest in interface ITestNGMethod
Returns:
true if this method was annotated with @Test

isBeforeSuiteConfiguration

public boolean isBeforeSuiteConfiguration()

Specified by:
isBeforeSuiteConfiguration in interface ITestNGMethod
Returns:
true if this method was annotated with @Configuration and beforeSuite = true

isAfterSuiteConfiguration

public boolean isAfterSuiteConfiguration()

Specified by:
isAfterSuiteConfiguration in interface ITestNGMethod
Returns:
true if this method was annotated with @Configuration and afterSuite = true

isBeforeTestConfiguration

public boolean isBeforeTestConfiguration()

Specified by:
isBeforeTestConfiguration in interface ITestNGMethod
Returns:
true if this method is a @BeforeTest (@Configuration beforeTest=true)

isAfterTestConfiguration

public boolean isAfterTestConfiguration()

Specified by:
isAfterTestConfiguration in interface ITestNGMethod
Returns:
true if this method is an @AfterTest (@Configuration afterTest=true)

isBeforeGroupsConfiguration

public boolean isBeforeGroupsConfiguration()

Specified by:
isBeforeGroupsConfiguration in interface ITestNGMethod

isAfterGroupsConfiguration

public boolean isAfterGroupsConfiguration()

Specified by:
isAfterGroupsConfiguration in interface ITestNGMethod

isBeforeClassConfiguration

public boolean isBeforeClassConfiguration()

Specified by:
isBeforeClassConfiguration in interface ITestNGMethod
Returns:
true if this method was annotated with @Configuration and beforeClassMethod = true

isAfterClassConfiguration

public boolean isAfterClassConfiguration()

Specified by:
isAfterClassConfiguration in interface ITestNGMethod
Returns:
true if this method was annotated with @Configuration and beforeClassMethod = false

isBeforeMethodConfiguration

public boolean isBeforeMethodConfiguration()

Specified by:
isBeforeMethodConfiguration in interface ITestNGMethod
Returns:
true if this method was annotated with @Configuration and beforeTestMethod = true

isAfterMethodConfiguration

public boolean isAfterMethodConfiguration()

Specified by:
isAfterMethodConfiguration in interface ITestNGMethod
Returns:
true if this method was annotated with @Configuration and beforeTestMethod = false

getTimeOut

public long getTimeOut()

Specified by:
getTimeOut in interface ITestNGMethod
Returns:
The timeout in milliseconds.

getInvocationCount

public int getInvocationCount()

Specified by:
getInvocationCount in interface ITestNGMethod
Returns:
the number of times this method needs to be invoked.

setInvocationCount

public void setInvocationCount(int counter)
No-op.

Specified by:
setInvocationCount in interface ITestNGMethod

getSuccessPercentage

public int getSuccessPercentage()
Default value for successPercentage.

Specified by:
getSuccessPercentage in interface ITestNGMethod
Returns:
the success percentage for this method (between 0 and 100).

getId

public java.lang.String getId()

Specified by:
getId in interface ITestNGMethod
Returns:
The id of the thread this method was run in.

setId

public void setId(java.lang.String id)

Specified by:
setId in interface ITestNGMethod

getDate

public long getDate()

Specified by:
getDate in interface ITestNGMethod
Returns:
Returns the date.

setDate

public void setDate(long date)

Specified by:
setDate in interface ITestNGMethod
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 interface ITestNGMethod

equals

public boolean equals(java.lang.Object obj)
Compares two BaseTestMethod using the test class then the associated Java Method.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
This implementation returns the associated Java Method's hash code.

Overrides:
hashCode in class java.lang.Object

initGroups

protected void initGroups(java.lang.Class<?> annotationClass)
TODO cquezel JavaDoc.

Parameters:
annotationClass -

getAnnotationFinder

protected IAnnotationFinder getAnnotationFinder()
TODO cquezel JavaDoc.

Returns:

getIClass

protected IClass getIClass()
TODO cquezel JavaDoc.

Returns:

getSignature

protected java.lang.String getSignature()
TODO cquezel JavaDoc.

Returns:

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

getStringArray

protected java.lang.String[] getStringArray(java.lang.String[] methodArray,
                                            java.lang.String[] classArray)
TODO cquezel JavaDoc.

Parameters:
methodArray -
classArray -
Returns:

setGroups

protected void setGroups(java.lang.String[] groups)

setGroupsDependedUpon

protected void setGroupsDependedUpon(java.lang.String[] groups)

setMethodsDependedUpon

protected void setMethodsDependedUpon(java.lang.String[] methods)

addMethodDependedUpon

public void addMethodDependedUpon(java.lang.String method)

Specified by:
addMethodDependedUpon in interface ITestNGMethod

getMissingGroup

public java.lang.String getMissingGroup()
If a group was not found.

Specified by:
getMissingGroup in interface ITestNGMethod

setMissingGroup

public void setMissingGroup(java.lang.String group)

Specified by:
setMissingGroup in interface ITestNGMethod

getThreadPoolSize

public int getThreadPoolSize()

Specified by:
getThreadPoolSize in interface ITestNGMethod
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 interface ITestNGMethod
Parameters:
threadPoolSize -

setDescription

public void setDescription(java.lang.String description)
TODO cquezel JavaDoc.

Parameters:
description -

getDescription

public java.lang.String getDescription()

Specified by:
getDescription in interface ITestNGMethod

getBeforeGroups

public java.lang.String[] getBeforeGroups()
Before and After groups

Specified by:
getBeforeGroups in interface ITestNGMethod

getAfterGroups

public java.lang.String[] getAfterGroups()

Specified by:
getAfterGroups in interface ITestNGMethod

incrementCurrentInvocationCount

public void incrementCurrentInvocationCount()
Specified by:
incrementCurrentInvocationCount in interface ITestNGMethod

getCurrentInvocationCount

public int getCurrentInvocationCount()
Specified by:
getCurrentInvocationCount in interface ITestNGMethod

setParameterInvocationCount

public void setParameterInvocationCount(int n)
Specified by:
setParameterInvocationCount in interface ITestNGMethod

getParameterInvocationCount

public int getParameterInvocationCount()
Specified by:
getParameterInvocationCount in interface ITestNGMethod

clone

public abstract ITestNGMethod clone()
Specified by:
clone in interface ITestNGMethod
Overrides:
clone in class java.lang.Object

getRetryAnalyzer

public IRetryAnalyzer getRetryAnalyzer()
Specified by:
getRetryAnalyzer in interface ITestNGMethod

setRetryAnalyzer

public void setRetryAnalyzer(IRetryAnalyzer retryAnalyzer)
Specified by:
setRetryAnalyzer in interface ITestNGMethod

skipFailedInvocations

public boolean skipFailedInvocations()
Specified by:
skipFailedInvocations in interface ITestNGMethod

setSkipFailedInvocations

public void setSkipFailedInvocations(boolean s)
Specified by:
setSkipFailedInvocations in interface ITestNGMethod


Copyright © 2010. All Rights Reserved.