Package org.testng.internal
Class TestResult
- java.lang.Object
-
- org.testng.internal.TestResult
-
- All Implemented Interfaces:
java.lang.Comparable<ITestResult>,IAlterTestName,IAttributes,ITestResult
public class TestResult extends java.lang.Object implements ITestResult, IAlterTestName
This class represents the result of a test.
-
-
Field Summary
Fields Modifier and Type Field Description private IAttributesm_attributesprivate ITestContextm_contextprivate longm_endMillisprivate java.lang.Stringm_hostprivate java.lang.Objectm_instanceprivate java.lang.Stringm_instanceNameprivate ITestNGMethodm_methodprivate java.lang.Stringm_nameprivate java.lang.Object[]m_parametersprivate longm_startMillisprivate intm_statusprivate IClassm_testClassprivate java.lang.Throwablem_throwableprivate intparameterIndex-
Fields inherited from interface org.testng.ITestResult
CREATED, FAILURE, SKIP, STARTED, SUCCESS, SUCCESS_PERCENTAGE_FAILURE
-
-
Constructor Summary
Constructors Constructor Description TestResult()TestResult(java.lang.Object instance, ITestNGMethod method, java.lang.Throwable throwable, ITestContext context)TestResult(IClass testClass, java.lang.Object instance, ITestNGMethod method, java.lang.Throwable throwable, long start, long end, ITestContext context)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(ITestResult comparison)java.lang.ObjectgetAttribute(java.lang.String name)java.util.Set<java.lang.String>getAttributeNames()longgetEndMillis()java.lang.StringgetHost()java.lang.ObjectgetInstance()The instance on which this method was run.java.lang.StringgetInstanceName()ITestNGMethodgetMethod()java.lang.StringgetName()intgetParameterIndex()java.lang.Object[]getParameters()longgetStartMillis()intgetStatus()IClassgetTestClass()ITestContextgetTestContext()java.lang.StringgetTestName()If this result's related instance implements ITest or use @Test(testName=...), returns its test name, otherwise returns null.java.lang.ThrowablegetThrowable()voidinit(IClass testClass, java.lang.Object instance, ITestNGMethod method, java.lang.Throwable throwable, long start, long end, ITestContext context)booleanisSuccess()java.lang.ObjectremoveAttribute(java.lang.String name)Remove the attributevoidsetAttribute(java.lang.String name, java.lang.Object value)Set a custom attribute.voidsetContext(ITestContext context)voidsetEndMillis(long millis)voidsetHost(java.lang.String host)voidsetMethod(ITestNGMethod method)(package private) voidsetParameterIndex(int parameterIndex)voidsetParameters(java.lang.Object[] parameters)voidsetStatus(int status)voidsetTestClass(IClass testClass)voidsetTestName(java.lang.String name)voidsetThrowable(java.lang.Throwable throwable)java.lang.StringtoString()private static java.lang.StringtoString(int status)
-
-
-
Field Detail
-
m_testClass
private IClass m_testClass
-
m_method
private ITestNGMethod m_method
-
m_status
private int m_status
-
m_throwable
private java.lang.Throwable m_throwable
-
m_startMillis
private long m_startMillis
-
m_endMillis
private long m_endMillis
-
m_name
private java.lang.String m_name
-
m_host
private java.lang.String m_host
-
m_parameters
private java.lang.Object[] m_parameters
-
m_instance
private java.lang.Object m_instance
-
m_instanceName
private java.lang.String m_instanceName
-
m_context
private ITestContext m_context
-
parameterIndex
private int parameterIndex
-
m_attributes
private final IAttributes m_attributes
-
-
Constructor Detail
-
TestResult
public TestResult()
-
TestResult
public TestResult(java.lang.Object instance, ITestNGMethod method, java.lang.Throwable throwable, ITestContext context)
-
TestResult
public TestResult(IClass testClass, java.lang.Object instance, ITestNGMethod method, java.lang.Throwable throwable, long start, long end, ITestContext context)
-
-
Method Detail
-
init
public void init(IClass testClass, java.lang.Object instance, ITestNGMethod method, java.lang.Throwable throwable, long start, long end, ITestContext context)
-
setEndMillis
public void setEndMillis(long millis)
- Specified by:
setEndMillisin interfaceITestResult
-
getTestName
public java.lang.String getTestName()
If this result's related instance implements ITest or use @Test(testName=...), returns its test name, otherwise returns null.- Specified by:
getTestNamein interfaceITestResult
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfaceITestResult- Returns:
- The name of this TestResult, typically identical to the name of the method.
-
getMethod
public ITestNGMethod getMethod()
- Specified by:
getMethodin interfaceITestResult- Returns:
- Returns the method.
-
setMethod
public void setMethod(ITestNGMethod method)
- Parameters:
method- The method to set.
-
getStatus
public int getStatus()
- Specified by:
getStatusin interfaceITestResult- Returns:
- Returns the status.
-
setStatus
public void setStatus(int status)
- Specified by:
setStatusin interfaceITestResult- Parameters:
status- The status to set.
-
isSuccess
public boolean isSuccess()
- Specified by:
isSuccessin interfaceITestResult- Returns:
- true if if this test run is a SUCCESS
-
getTestClass
public IClass getTestClass()
- Specified by:
getTestClassin interfaceITestResult- Returns:
- Returns the testClass.
-
setTestClass
public void setTestClass(IClass testClass)
- Parameters:
testClass- The testClass to set.
-
getThrowable
public java.lang.Throwable getThrowable()
- Specified by:
getThrowablein interfaceITestResult- Returns:
- Returns the throwable.
-
setThrowable
public void setThrowable(java.lang.Throwable throwable)
- Specified by:
setThrowablein interfaceITestResult- Parameters:
throwable- The throwable to set.
-
getEndMillis
public long getEndMillis()
- Specified by:
getEndMillisin interfaceITestResult- Returns:
- Returns the endMillis.
-
getStartMillis
public long getStartMillis()
- Specified by:
getStartMillisin interfaceITestResult- Returns:
- Returns the startMillis.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toString
private static java.lang.String toString(int status)
-
getHost
public java.lang.String getHost()
- Specified by:
getHostin interfaceITestResult- Returns:
- The host where this suite was run, or null if it was run locally. The returned string has the form: host:port
-
setHost
public void setHost(java.lang.String host)
-
getParameters
public java.lang.Object[] getParameters()
- Specified by:
getParametersin interfaceITestResult- Returns:
- The parameters this method was invoked with.
-
setParameters
public void setParameters(java.lang.Object[] parameters)
- Specified by:
setParametersin interfaceITestResult
-
getInstance
public java.lang.Object getInstance()
Description copied from interface:ITestResultThe instance on which this method was run.- Specified by:
getInstancein interfaceITestResult
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
- Specified by:
getAttributein interfaceIAttributes- Parameters:
name- The name of the attribute to return
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)Description copied from interface:IAttributesSet a custom attribute.- Specified by:
setAttributein interfaceIAttributes
-
getAttributeNames
public java.util.Set<java.lang.String> getAttributeNames()
- Specified by:
getAttributeNamesin interfaceIAttributes- Returns:
- all the attributes names.
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String name)
Description copied from interface:IAttributesRemove the attribute- Specified by:
removeAttributein interfaceIAttributes- Returns:
- the attribute value if found, null otherwise
-
getTestContext
public ITestContext getTestContext()
- Specified by:
getTestContextin interfaceITestResult- Returns:
- the
ITestContextfor this test result.
-
setContext
public void setContext(ITestContext context)
-
compareTo
public int compareTo(ITestResult comparison)
- Specified by:
compareToin interfacejava.lang.Comparable<ITestResult>
-
getInstanceName
public java.lang.String getInstanceName()
- Specified by:
getInstanceNamein interfaceITestResult
-
setTestName
public void setTestName(java.lang.String name)
- Specified by:
setTestNamein interfaceIAlterTestName- Parameters:
name- - The new name to be used as a test name
-
setParameterIndex
void setParameterIndex(int parameterIndex)
-
getParameterIndex
public int getParameterIndex()
-
-