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 TypeFieldDescriptionprivate long
protected String[]
protected final IAnnotationFinder
protected String[]
protected AtomicInteger
protected long
private String
private boolean
private final Collection<Integer>
protected String[]
protected String[]
protected String
private boolean
private final Object
private int
private long
private boolean
protected final ConstructorOrMethod
protected final Class<?>
private final String
protected String[]
private String
private int
private int
private IRetryAnalyzer
private Class<? extends IRetryAnalyzer>
private String
private boolean
protected ITestClass
The test class on which the test method was found.private final Map<String,
IRetryAnalyzer> private long
private XmlTest
private static final Pattern
-
Constructor Summary
ConstructorsConstructorDescriptionBaseTestMethod
(String methodName, ConstructorOrMethod com, IAnnotationFinder annotationFinder, Object instance) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFailedInvocationNumber
(int number) The list of invocation numbers that failed, which is only applicable for methods that have a data provider.void
addMethodDependedUpon
(String method) private String[]
calculateGroupsTouseConsideringValuesAndGroupValues
(Class<? extends ITestOrConfiguration> annotationClass, String[] groups) calculateXmlGroupDependencies
(XmlTest xmlTest) boolean
canRunFromClass
(IClass testClass) abstract ITestNGMethod
clone()
private String
boolean
Compares two BaseTestMethod using the test class then the associated Java Method.findMethodParameters
(XmlTest test) String[]
protected IAnnotationFinder
String[]
int
long
getDate()
boolean
String[]
String[]
protected IClass
getId()
long[]
Needed for serialization.int
int
Which invocation numbers of this method should be used (only applicable if it uses a data provider).long
long
Returns the method name.String[]
int
Class<?>[]
int
The scheduling priority.getRealClass().getName() + "." + getMethodName()Class<?>
getRetryAnalyzer
(ITestResult result) Class<? extends IRetryAnalyzer>
private IRetryAnalyzer
protected String
protected String[]
getStringArray
(String[] methodArray, String[] classArray) int
Default value for successPercentage.int
long
int
hashCode()
This implementation returns the associated Java Method's hash code.boolean
boolean
void
protected void
initBeforeAfterGroups
(Class<? extends ITestOrConfiguration> annotationClass, String[] groups) protected void
initGroups
(Class<? extends ITestOrConfiguration> annotationClass) private void
initRestOfGroupDependencies
(Class<? extends ITestOrConfiguration> annotationClass) private String
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
isTest()
protected void
setAlwaysRun
(boolean alwaysRun) void
setDate
(long date) void
setDescription
(String description) void
setEnabled
(boolean enabled) protected void
protected void
setGroupsDependedUpon
(String[] groups, Collection<String> xmlGroupDependencies) void
void
setIgnoreMissingDependencies
(boolean i) void
setInterceptedPriority
(int priority) void
setInvocationCount
(int counter) No-op.void
setInvocationNumbers
(List<Integer> numbers) void
setInvocationTimeOut
(long timeOut) void
setInvokedAt
(long date) protected void
setMethodsDependedUpon
(String[] methods) void
setMissingGroup
(String group) void
setMoreInvocationChecker
(Callable<Boolean> moreInvocationChecker) void
setParameterInvocationCount
(int n) void
setPriority
(int priority) void
setRetryAnalyzerClass
(Class<? extends IRetryAnalyzer> clazz) void
setSkipFailedInvocations
(boolean s) void
Sets the test class having this method.void
setThreadPoolSize
(int threadPoolSize) No-op.void
setTimeOut
(long timeOut) void
setXmlTest
(XmlTest xmlTest) boolean
(package private) static StringBuilder
stringify
(String cls, ConstructorOrMethod method) toString()
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
-
Field Details
-
SPACE_SEPARATOR_PATTERN
-
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_signature
-
m_id
-
m_date
protected long m_date -
m_annotationFinder
-
m_groups
-
m_groupsDependedUpon
-
m_methodsDependedUpon
-
m_beforeGroups
-
m_afterGroups
-
m_isAlwaysRun
private boolean m_isAlwaysRun -
m_enabled
private boolean m_enabled -
m_methodName
-
m_missingGroup
-
m_description
-
m_currentInvocationCount
-
m_parameterInvocationCount
private int m_parameterInvocationCount -
m_moreInvocationChecker
-
m_retryAnalyzer
-
m_retryAnalyzerClass
-
m_skipFailedInvocations
private boolean m_skipFailedInvocations -
m_invocationTimeOut
private long m_invocationTimeOut -
m_invocationNumbers
-
m_failedInvocationNumbers
-
m_timeOut
private long m_timeOut -
m_ignoreMissingDependencies
private boolean m_ignoreMissingDependencies -
m_priority
private int m_priority -
m_interceptedPriority
private int m_interceptedPriority -
m_xmlTest
-
m_instance
-
m_testMethodToRetryAnalyzer
-
invocationTime
private long invocationTime
-
-
Constructor Details
-
BaseTestMethod
public BaseTestMethod(String methodName, ConstructorOrMethod com, IAnnotationFinder annotationFinder, Object instance)
-
-
Method Details
-
isAlwaysRun
public boolean isAlwaysRun()- Specified by:
isAlwaysRun
in interfaceITestNGMethod
- Returns:
- true if this method is alwaysRun=true
-
setAlwaysRun
protected void setAlwaysRun(boolean alwaysRun) -
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
- Specified by:
getTestClass
in interfaceITestNGMethod
-
setTestClass
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
Returns the method name. This is needed for serialization because methods are not Serializable.- Specified by:
getMethodName
in interfaceITestNGMethod
- Returns:
- the method name.
-
getInstance
- Specified by:
getInstance
in interfaceITestNGMethod
-
getInstanceHashCodes
public long[] getInstanceHashCodes()Needed for serialization.- Specified by:
getInstanceHashCodes
in interfaceITestNGMethod
- Returns:
- The hashcode of instances
-
getGroups
- Specified by:
getGroups
in interfaceITestNGMethod
- Returns:
- the addition of groups defined on the class and on this method.
-
getGroupsDependedUpon
- Specified by:
getGroupsDependedUpon
in interfaceITestNGMethod
- Returns:
- The groups this method depends on, possibly added to the groups declared on the class.
-
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
- Specified by:
getId
in interfaceITestNGMethod
- Returns:
- The id of the thread this method was run in.
-
setId
- 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
- Specified by:
canRunFromClass
in 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) -
calculateGroupsTouseConsideringValuesAndGroupValues
private String[] calculateGroupsTouseConsideringValuesAndGroupValues(Class<? extends ITestOrConfiguration> annotationClass, String[] groups) -
initRestOfGroupDependencies
-
calculateXmlGroupDependencies
-
getAnnotationFinder
-
getIClass
-
stringify
-
computeSignature
-
getSimpleName
-
instanceParameters
-
getSignature
-
toString
-
getStringArray
-
setGroups
-
setGroupsDependedUpon
-
setMethodsDependedUpon
-
addMethodDependedUpon
- Specified by:
addMethodDependedUpon
in interfaceITestNGMethod
-
getMissingGroup
- Specified by:
getMissingGroup
in interfaceITestNGMethod
- Returns:
- If a group was not found.
-
setMissingGroup
- 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
- Specified by:
setDescription
in interfaceITestNGMethod
-
getDescription
- Specified by:
getDescription
in interfaceITestNGMethod
-
setEnabled
public void setEnabled(boolean enabled) -
getEnabled
public boolean getEnabled()- Specified by:
getEnabled
in interfaceITestNGMethod
-
getBeforeGroups
- Specified by:
getBeforeGroups
in interfaceITestNGMethod
-
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
- Specified by:
setMoreInvocationChecker
in interfaceITestNGMethod
-
hasMoreInvocation
public boolean hasMoreInvocation()- Specified by:
hasMoreInvocation
in interfaceITestNGMethod
-
clone
- Specified by:
clone
in interfaceITestNGMethod
- Overrides:
clone
in classObject
-
getRetryAnalyzer
- Specified by:
getRetryAnalyzer
in interfaceITestNGMethod
-
setRetryAnalyzerClass
- Specified by:
setRetryAnalyzerClass
in interfaceITestNGMethod
-
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()- Specified by:
getInvocationTimeOut
in interfaceITestNGMethod
- Returns:
- The time under which all invocationCount methods need to complete by.
-
ignoreMissingDependencies
public boolean ignoreMissingDependencies()- Specified by:
ignoreMissingDependencies
in interfaceITestNGMethod
-
setIgnoreMissingDependencies
public void setIgnoreMissingDependencies(boolean i) - Specified by:
setIgnoreMissingDependencies
in interfaceITestNGMethod
-
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 the<include invocationNumbers="...">
tag.- Specified by:
getInvocationNumbers
in interfaceITestNGMethod
- Returns:
- The list of invocation numbers
-
setInvocationNumbers
- Specified by:
setInvocationNumbers
in interfaceITestNGMethod
-
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
- Parameters:
number
- The invocation number that failed
-
getPriority
public int getPriority()Description copied from interface:ITestNGMethod
The scheduling priority. Lower priorities get scheduled first.- Specified by:
getPriority
in interfaceITestNGMethod
- Returns:
- The priority value
-
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
- Specified by:
getXmlTest
in interfaceITestNGMethod
- Returns:
- the XmlTest this method belongs to.
-
setXmlTest
-
getConstructorOrMethod
- Specified by:
getConstructorOrMethod
in interfaceITestNGMethod
-
getParameterTypes
- Specified by:
getParameterTypes
in interfaceITestNGMethod
-
findMethodParameters
- Specified by:
findMethodParameters
in interfaceITestNGMethod
- Parameters:
test
- - TheXmlTest
object.- Returns:
- the parameters found in the include tag, if any
-
getQualifiedName
Description copied from interface:ITestNGMethod
getRealClass().getName() + "." + getMethodName()- Specified by:
getQualifiedName
in interfaceITestNGMethod
- Returns:
- qualified name for this method
-
getFactoryMethodParamsInfo
- Specified by:
getFactoryMethodParamsInfo
in interfaceITestNGMethod
- Returns:
- - A
IParameterInfo
object that represents details about the parameters associated with the factory method.
-
setInvokedAt
public void setInvokedAt(long date) - Specified by:
setInvokedAt
in interfaceIInvocationStatus
- Parameters:
date
- - The timestamp at which a method was invoked.
-
getInvocationTime
public long getInvocationTime()- Specified by:
getInvocationTime
in interfaceIInvocationStatus
- Returns:
- - The timestamp at which a method got invoked.
-
getRetryAnalyzerConsideringMethodParameters
-