org.testng.junit
Class JUnitUtils.JUnitTestMethod

java.lang.Object
  extended by org.testng.junit.JUnitUtils.JUnitTestMethod
All Implemented Interfaces:
Serializable, Cloneable, Comparable, ITestNGMethod
Enclosing class:
JUnitUtils

public static class JUnitUtils.JUnitTestMethod
extends Object
implements ITestNGMethod

An ITestNMethod implementation for test methods in JUnit.

Author:
Alexandru Popescu
See Also:
Serialized Form

Constructor Summary
JUnitUtils.JUnitTestMethod(junit.framework.Test test, JUnitUtils.JUnitTestClass testClass)
           
 
Method Summary
 void addFailedInvocationNumber(int number)
          The list of invocation numbers that failed, which is only applicable for methods that have a data provider.
 void addMethodDependedUpon(String methodName)
           
 boolean canRunFromClass(IClass testClass)
          Returns if this ITestNGMethod can be invoked from within IClass.
 ITestNGMethod clone()
           
 int compareTo(Object o)
           
 String[] getAfterGroups()
           
 String[] getBeforeGroups()
          Before and After groups
 int getCurrentInvocationCount()
           
 long getDate()
           
 String getDescription()
           
 List<Integer> getFailedInvocationNumbers()
           
 String[] getGroups()
           
 String[] getGroupsDependedUpon()
           
 String getId()
           
 long[] getInstanceHashCodes()
          Needed for serialization.
 Object[] getInstances()
           
 int getInvocationCount()
           
 List<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.
 Method getMethod()
          Returns the corresponding Java test method.
 String getMethodName()
          Returns the method name.
 String[] getMethodsDependedUpon()
           
 String getMissingGroup()
          If a group was not found.
 int getParameterInvocationCount()
           
 int getPriority()
          The scheduling priority.
 Class getRealClass()
           
 IRetryAnalyzer getRetryAnalyzer()
           
 int getSuccessPercentage()
           
 ITestClass getTestClass()
           
 int getThreadPoolSize()
           
 long getTimeOut()
           
 boolean ignoreMissingDependencies()
           
 void incrementCurrentInvocationCount()
           
 boolean isAfterClassConfiguration()
           
 boolean isAfterGroupsConfiguration()
           
 boolean isAfterMethodConfiguration()
           
 boolean isAfterSuiteConfiguration()
           
 boolean isAfterTestConfiguration()
           
 boolean isAlwaysRun()
           
 boolean isBeforeClassConfiguration()
           
 boolean isBeforeGroupsConfiguration()
           
 boolean isBeforeMethodConfiguration()
           
 boolean isBeforeSuiteConfiguration()
           
 boolean isBeforeTestConfiguration()
           
 boolean isFirstTimeOnly()
           
 boolean isLastTimeOnly()
           
 boolean isTest()
           
 void setDate(long date)
           
 void setId(String id)
           
 void setIgnoreMissingDependencies(boolean ignore)
           
 void setInvocationCount(int count)
           
 void setInvocationNumbers(List<Integer> count)
           
 void setMissingGroup(String group)
           
 void setParameterInvocationCount(int n)
           
 void setPriority(int priority)
           
 void setRetryAnalyzer(IRetryAnalyzer retryAnalyzer)
           
 void setSkipFailedInvocations(boolean skip)
           
 void setTestClass(ITestClass cls)
          Sets the test class having this method.
 void setThreadPoolSize(int threadPoolSize)
           
 boolean skipFailedInvocations()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JUnitUtils.JUnitTestMethod

public JUnitUtils.JUnitTestMethod(junit.framework.Test test,
                                  JUnitUtils.JUnitTestClass testClass)
Method Detail

getDate

public long getDate()
Specified by:
getDate in interface ITestNGMethod
See Also:
ITestNGMethod.getDate()

getDescription

public String getDescription()
Specified by:
getDescription in interface ITestNGMethod
See Also:
ITestNGMethod.getDescription()

getId

public String getId()
Specified by:
getId in interface ITestNGMethod
Returns:
The id of the thread this method was run in.
See Also:
ITestNGMethod.getId()

getInstanceHashCodes

public long[] getInstanceHashCodes()
Description copied from interface: ITestNGMethod
Needed for serialization.

Specified by:
getInstanceHashCodes in interface ITestNGMethod
See Also:
ITestNGMethod.getInstanceHashCodes()

getInstances

public 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.
See Also:
ITestNGMethod.getInstances()

getMethod

public Method getMethod()
Description copied from interface: ITestNGMethod
Returns the corresponding Java test method.

Specified by:
getMethod in interface ITestNGMethod
Returns:
the corresponding Java test method.
See Also:
ITestNGMethod.getMethod()

getMethodName

public String getMethodName()
Description copied from interface: ITestNGMethod
Returns the method name. This is needed for serialization because methods are not Serializable.

Specified by:
getMethodName in interface ITestNGMethod
Returns:
the method name.
See Also:
ITestNGMethod.getMethodName()

getRealClass

public 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).
See Also:
ITestNGMethod.getRealClass()

setDate

public void setDate(long date)
Specified by:
setDate in interface ITestNGMethod
See Also:
ITestNGMethod.setDate(long)

setId

public void setId(String id)
Specified by:
setId in interface ITestNGMethod
See Also:
org.testng.ITestNGMethod#setId(long)

compareTo

public int compareTo(Object o)
Specified by:
compareTo in interface Comparable

isTest

public boolean isTest()
Specified by:
isTest in interface ITestNGMethod
Returns:
true if this method was annotated with @Test
See Also:
ITestNGMethod.isTest()

canRunFromClass

public boolean canRunFromClass(IClass testClass)
Description copied from interface: ITestNGMethod
Returns if this ITestNGMethod can be invoked from within IClass.

Specified by:
canRunFromClass in interface ITestNGMethod
See Also:
ITestNGMethod.canRunFromClass(org.testng.IClass)

setTestClass

public void setTestClass(ITestClass cls)
Description copied from interface: ITestNGMethod
Sets the test class having this method. This is not necessarily the declaring class.

Specified by:
setTestClass in interface ITestNGMethod
Parameters:
cls - The test class having this method.
See Also:
ITestNGMethod.setTestClass(org.testng.ITestClass)

getTestClass

public ITestClass getTestClass()
Specified by:
getTestClass in interface ITestNGMethod
See Also:
ITestNGMethod.getTestClass()

addMethodDependedUpon

public void addMethodDependedUpon(String methodName)
Specified by:
addMethodDependedUpon in interface ITestNGMethod
See Also:
ITestNGMethod.addMethodDependedUpon(java.lang.String)

setMissingGroup

public void setMissingGroup(String group)
Specified by:
setMissingGroup in interface ITestNGMethod
See Also:
ITestNGMethod.setMissingGroup(java.lang.String)

getAfterGroups

public String[] getAfterGroups()
Specified by:
getAfterGroups in interface ITestNGMethod
See Also:
ITestNGMethod.getAfterGroups()

getBeforeGroups

public String[] getBeforeGroups()
Description copied from interface: ITestNGMethod
Before and After groups

Specified by:
getBeforeGroups in interface ITestNGMethod
See Also:
ITestNGMethod.getBeforeGroups()

getGroups

public String[] getGroups()
Specified by:
getGroups in interface ITestNGMethod
Returns:
The groups this method belongs to, possibly added to the groups declared on the class.
See Also:
ITestNGMethod.getGroups()

getGroupsDependedUpon

public String[] getGroupsDependedUpon()
Specified by:
getGroupsDependedUpon in interface ITestNGMethod
Returns:
The groups this method depends on, possibly added to the groups declared on the class.
See Also:
ITestNGMethod.getGroupsDependedUpon()

getInvocationCount

public int getInvocationCount()
Specified by:
getInvocationCount in interface ITestNGMethod
Returns:
the number of times this method needs to be invoked.
See Also:
ITestNGMethod.getInvocationCount()

getMethodsDependedUpon

public String[] getMethodsDependedUpon()
Specified by:
getMethodsDependedUpon in interface ITestNGMethod
Returns:
The methods this method depends on, possibly added to the methods declared on the class.
See Also:
ITestNGMethod.getMethodsDependedUpon()

getMissingGroup

public String getMissingGroup()
Description copied from interface: ITestNGMethod
If a group was not found.

Specified by:
getMissingGroup in interface ITestNGMethod
See Also:
ITestNGMethod.getMissingGroup()

getSuccessPercentage

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

getThreadPoolSize

public int getThreadPoolSize()
Specified by:
getThreadPoolSize in interface ITestNGMethod
Returns:
the number of threads to be used when invoking the method on parallel
See Also:
ITestNGMethod.getThreadPoolSize()

getTimeOut

public long getTimeOut()
Specified by:
getTimeOut in interface ITestNGMethod
Returns:
The timeout in milliseconds.
See Also:
ITestNGMethod.getTimeOut()

isAfterClassConfiguration

public boolean isAfterClassConfiguration()
Specified by:
isAfterClassConfiguration in interface ITestNGMethod
Returns:
true if this method was annotated with @Configuration and beforeClassMethod = false
See Also:
ITestNGMethod.isAfterClassConfiguration()

isAfterGroupsConfiguration

public boolean isAfterGroupsConfiguration()
Specified by:
isAfterGroupsConfiguration in interface ITestNGMethod
See Also:
ITestNGMethod.isAfterGroupsConfiguration()

isAfterMethodConfiguration

public boolean isAfterMethodConfiguration()
Specified by:
isAfterMethodConfiguration in interface ITestNGMethod
Returns:
true if this method was annotated with @Configuration and beforeTestMethod = false
See Also:
ITestNGMethod.isAfterMethodConfiguration()

isAfterSuiteConfiguration

public boolean isAfterSuiteConfiguration()
Specified by:
isAfterSuiteConfiguration in interface ITestNGMethod
Returns:
true if this method was annotated with @Configuration and afterSuite = true
See Also:
ITestNGMethod.isAfterSuiteConfiguration()

isAfterTestConfiguration

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

isAlwaysRun

public boolean isAlwaysRun()
Specified by:
isAlwaysRun in interface ITestNGMethod
Returns:
true if this method is alwaysRun=true
See Also:
ITestNGMethod.isAlwaysRun()

isBeforeClassConfiguration

public boolean isBeforeClassConfiguration()
Specified by:
isBeforeClassConfiguration in interface ITestNGMethod
Returns:
true if this method was annotated with @Configuration and beforeClassMethod = true
See Also:
ITestNGMethod.isBeforeClassConfiguration()

isBeforeGroupsConfiguration

public boolean isBeforeGroupsConfiguration()
Specified by:
isBeforeGroupsConfiguration in interface ITestNGMethod
See Also:
ITestNGMethod.isBeforeGroupsConfiguration()

isBeforeMethodConfiguration

public boolean isBeforeMethodConfiguration()
Specified by:
isBeforeMethodConfiguration in interface ITestNGMethod
Returns:
true if this method was annotated with @Configuration and beforeTestMethod = true
See Also:
ITestNGMethod.isBeforeMethodConfiguration()

isBeforeSuiteConfiguration

public boolean isBeforeSuiteConfiguration()
Specified by:
isBeforeSuiteConfiguration in interface ITestNGMethod
Returns:
true if this method was annotated with @Configuration and beforeSuite = true
See Also:
ITestNGMethod.isBeforeSuiteConfiguration()

isBeforeTestConfiguration

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

getCurrentInvocationCount

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

incrementCurrentInvocationCount

public void incrementCurrentInvocationCount()
Specified by:
incrementCurrentInvocationCount 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

toString

public String toString()
Overrides:
toString in class Object

clone

public ITestNGMethod clone()
Specified by:
clone in interface ITestNGMethod
Overrides:
clone in class Object

setInvocationCount

public void setInvocationCount(int count)
Specified by:
setInvocationCount in interface ITestNGMethod
See Also:
ITestNGMethod.setInvocationCount(int)

setThreadPoolSize

public void setThreadPoolSize(int threadPoolSize)
Specified by:
setThreadPoolSize in interface ITestNGMethod
See Also:
ITestNGMethod.setThreadPoolSize(int)

getRetryAnalyzer

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

setRetryAnalyzer

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

setSkipFailedInvocations

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

skipFailedInvocations

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

setIgnoreMissingDependencies

public void setIgnoreMissingDependencies(boolean ignore)
Specified by:
setIgnoreMissingDependencies in interface ITestNGMethod

ignoreMissingDependencies

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

isFirstTimeOnly

public boolean isFirstTimeOnly()

isLastTimeOnly

public boolean isLastTimeOnly()

getInvocationTimeOut

public long getInvocationTimeOut()
Description copied from interface: ITestNGMethod
The time under which all invocationCount methods need to complete by.

Specified by:
getInvocationTimeOut in interface ITestNGMethod

getInvocationNumbers

public List<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 the tag.

Specified by:
getInvocationNumbers in interface ITestNGMethod

setInvocationNumbers

public void setInvocationNumbers(List<Integer> count)
Specified by:
setInvocationNumbers in interface ITestNGMethod

getFailedInvocationNumbers

public List<Integer> getFailedInvocationNumbers()
Specified by:
getFailedInvocationNumbers in interface ITestNGMethod

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 interface ITestNGMethod

getPriority

public int getPriority()
Description copied from interface: ITestNGMethod
The scheduling priority. Lower priorities get scheduled first.

Specified by:
getPriority in interface ITestNGMethod

setPriority

public void setPriority(int priority)
Specified by:
setPriority in interface ITestNGMethod


Copyright © 2010. All Rights Reserved.