Package org.testng.internal
Class TestResult
- java.lang.Object
-
- org.testng.internal.TestResult
-
- All Implemented Interfaces:
Comparable<ITestResult>
,IAlterTestName
,IAttributes
,ITestResult
public class TestResult extends Object implements ITestResult, IAlterTestName
This class represents the result of a test.
-
-
Field Summary
-
Fields inherited from interface org.testng.ITestResult
CREATED, FAILURE, SKIP, STARTED, SUCCESS, SUCCESS_PERCENTAGE_FAILURE
-
-
Constructor Summary
Constructors Constructor Description TestResult()
TestResult(Object instance, ITestNGMethod method, Throwable throwable, ITestContext context)
TestResult(IClass testClass, Object instance, ITestNGMethod method, Throwable throwable, long start, long end, ITestContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(ITestResult comparison)
Object
getAttribute(String name)
Set<String>
getAttributeNames()
long
getEndMillis()
String
getHost()
Object
getInstance()
The instance on which this method was run.String
getInstanceName()
ITestNGMethod
getMethod()
String
getName()
int
getParameterIndex()
Object[]
getParameters()
long
getStartMillis()
int
getStatus()
IClass
getTestClass()
ITestContext
getTestContext()
String
getTestName()
If this result's related instance implements ITest or use @Test(testName=...), returns its test name, otherwise returns null.Throwable
getThrowable()
void
init(IClass testClass, Object instance, ITestNGMethod method, Throwable throwable, long start, long end, ITestContext context)
boolean
isSuccess()
Object
removeAttribute(String name)
Remove the attributevoid
setAttribute(String name, Object value)
Set a custom attribute.void
setContext(ITestContext context)
void
setEndMillis(long millis)
void
setHost(String host)
void
setMethod(ITestNGMethod method)
void
setParameters(Object[] parameters)
void
setStatus(int status)
void
setTestClass(IClass testClass)
void
setTestName(String name)
void
setThrowable(Throwable throwable)
String
toString()
-
-
-
Constructor Detail
-
TestResult
public TestResult()
-
TestResult
public TestResult(Object instance, ITestNGMethod method, Throwable throwable, ITestContext context)
-
TestResult
public TestResult(IClass testClass, Object instance, ITestNGMethod method, Throwable throwable, long start, long end, ITestContext context)
-
-
Method Detail
-
init
public void init(IClass testClass, Object instance, ITestNGMethod method, Throwable throwable, long start, long end, ITestContext context)
-
setEndMillis
public void setEndMillis(long millis)
- Specified by:
setEndMillis
in interfaceITestResult
-
getTestName
public String getTestName()
If this result's related instance implements ITest or use @Test(testName=...), returns its test name, otherwise returns null.- Specified by:
getTestName
in interfaceITestResult
-
getName
public String getName()
- Specified by:
getName
in interfaceITestResult
- Returns:
- The name of this TestResult, typically identical to the name of the method.
-
getMethod
public ITestNGMethod getMethod()
- Specified by:
getMethod
in interfaceITestResult
- Returns:
- Returns the method.
-
setMethod
public void setMethod(ITestNGMethod method)
- Parameters:
method
- The method to set.
-
getStatus
public int getStatus()
- Specified by:
getStatus
in interfaceITestResult
- Returns:
- Returns the status.
-
setStatus
public void setStatus(int status)
- Specified by:
setStatus
in interfaceITestResult
- Parameters:
status
- The status to set.
-
isSuccess
public boolean isSuccess()
- Specified by:
isSuccess
in interfaceITestResult
- Returns:
- true if if this test run is a SUCCESS
-
getTestClass
public IClass getTestClass()
- Specified by:
getTestClass
in interfaceITestResult
- Returns:
- Returns the testClass.
-
setTestClass
public void setTestClass(IClass testClass)
- Parameters:
testClass
- The testClass to set.
-
getThrowable
public Throwable getThrowable()
- Specified by:
getThrowable
in interfaceITestResult
- Returns:
- Returns the throwable.
-
setThrowable
public void setThrowable(Throwable throwable)
- Specified by:
setThrowable
in interfaceITestResult
- Parameters:
throwable
- The throwable to set.
-
getEndMillis
public long getEndMillis()
- Specified by:
getEndMillis
in interfaceITestResult
- Returns:
- Returns the endMillis.
-
getStartMillis
public long getStartMillis()
- Specified by:
getStartMillis
in interfaceITestResult
- Returns:
- Returns the startMillis.
-
getHost
public String getHost()
- Specified by:
getHost
in 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(String host)
-
getParameters
public Object[] getParameters()
- Specified by:
getParameters
in interfaceITestResult
- Returns:
- The parameters this method was invoked with.
-
setParameters
public void setParameters(Object[] parameters)
- Specified by:
setParameters
in interfaceITestResult
-
getInstance
public Object getInstance()
Description copied from interface:ITestResult
The instance on which this method was run.- Specified by:
getInstance
in interfaceITestResult
-
getAttribute
public Object getAttribute(String name)
- Specified by:
getAttribute
in interfaceIAttributes
- Parameters:
name
- The name of the attribute to return
-
setAttribute
public void setAttribute(String name, Object value)
Description copied from interface:IAttributes
Set a custom attribute.- Specified by:
setAttribute
in interfaceIAttributes
-
getAttributeNames
public Set<String> getAttributeNames()
- Specified by:
getAttributeNames
in interfaceIAttributes
- Returns:
- all the attributes names.
-
removeAttribute
public Object removeAttribute(String name)
Description copied from interface:IAttributes
Remove the attribute- Specified by:
removeAttribute
in interfaceIAttributes
- Returns:
- the attribute value if found, null otherwise
-
getTestContext
public ITestContext getTestContext()
- Specified by:
getTestContext
in interfaceITestResult
- Returns:
- the
ITestContext
for this test result.
-
setContext
public void setContext(ITestContext context)
-
compareTo
public int compareTo(ITestResult comparison)
- Specified by:
compareTo
in interfaceComparable<ITestResult>
-
getInstanceName
public String getInstanceName()
- Specified by:
getInstanceName
in interfaceITestResult
-
setTestName
public void setTestName(String name)
- Specified by:
setTestName
in interfaceIAlterTestName
- Parameters:
name
- - The new name to be used as a test name
-
getParameterIndex
public int getParameterIndex()
-
-