Package org.testng.internal
Class TestResult
- java.lang.Object
-
- org.testng.internal.TestResult
-
- All Implemented Interfaces:
java.lang.Comparable<ITestResult>
,IAttributes
,ITestResult
public class TestResult extends java.lang.Object implements ITestResult
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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(ITestResult comparison)
java.lang.Object
getAttribute(java.lang.String name)
java.util.Set<java.lang.String>
getAttributeNames()
long
getEndMillis()
java.lang.Object[]
getFactoryParameters()
java.lang.String
getHost()
java.lang.Object
getInstance()
The instance on which this method was run.java.lang.String
getInstanceName()
ITestNGMethod
getMethod()
java.lang.String
getName()
int
getParameterIndex()
java.lang.Object[]
getParameters()
java.util.List<ITestNGMethod>
getSkipCausedBy()
long
getStartMillis()
int
getStatus()
IClass
getTestClass()
ITestContext
getTestContext()
java.lang.String
getTestName()
If this result's related instance implements ITest or use @Test(testName=...), returns its test name, otherwise returns null.java.lang.Throwable
getThrowable()
boolean
isSuccess()
static TestResult
newContextAwareTestResult(ITestNGMethod method, ITestContext ctx)
static TestResult
newEmptyTestResult()
static TestResult
newEndTimeAwareTestResult(ITestNGMethod method, ITestContext ctx, java.lang.Throwable t, long start)
static TestResult
newTestResultFor(ITestNGMethod method)
static TestResult
newTestResultFrom(TestResult result, ITestNGMethod method, ITestContext ctx, long start)
static TestResult
newTestResultWithCauseAs(ITestNGMethod method, ITestContext ctx, java.lang.Throwable t)
java.lang.Object
removeAttribute(java.lang.String name)
Remove the attributevoid
setAttribute(java.lang.String name, java.lang.Object value)
Set a custom attribute.void
setContext(ITestContext context)
void
setEndMillis(long millis)
void
setHost(java.lang.String host)
void
setMethod(ITestNGMethod method)
void
setParameters(java.lang.Object[] parameters)
void
setStatus(int status)
void
setTestName(java.lang.String name)
void
setThrowable(java.lang.Throwable throwable)
void
setWasRetried(boolean wasRetried)
java.lang.String
toString()
boolean
wasRetried()
-
-
-
Method Detail
-
newEmptyTestResult
public static TestResult newEmptyTestResult()
-
newTestResultFor
public static TestResult newTestResultFor(ITestNGMethod method)
-
newContextAwareTestResult
public static TestResult newContextAwareTestResult(ITestNGMethod method, ITestContext ctx)
-
newTestResultWithCauseAs
public static TestResult newTestResultWithCauseAs(ITestNGMethod method, ITestContext ctx, java.lang.Throwable t)
-
newEndTimeAwareTestResult
public static TestResult newEndTimeAwareTestResult(ITestNGMethod method, ITestContext ctx, java.lang.Throwable t, long start)
-
newTestResultFrom
public static TestResult newTestResultFrom(TestResult result, ITestNGMethod method, ITestContext ctx, long start)
-
setEndMillis
public void setEndMillis(long millis)
- Specified by:
setEndMillis
in 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:
getTestName
in interfaceITestResult
-
getName
public java.lang.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.
-
getThrowable
public java.lang.Throwable getThrowable()
- Specified by:
getThrowable
in interfaceITestResult
- Returns:
- Returns the throwable.
-
setThrowable
public void setThrowable(java.lang.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.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getHost
public java.lang.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(java.lang.String host)
-
getParameters
public java.lang.Object[] getParameters()
- Specified by:
getParameters
in interfaceITestResult
- Returns:
- The parameters this method was invoked with.
-
setParameters
public void setParameters(java.lang.Object[] parameters)
- Specified by:
setParameters
in interfaceITestResult
-
getInstance
public java.lang.Object getInstance()
Description copied from interface:ITestResult
The instance on which this method was run.- Specified by:
getInstance
in interfaceITestResult
-
getFactoryParameters
public java.lang.Object[] getFactoryParameters()
- Specified by:
getFactoryParameters
in interfaceITestResult
- Returns:
- - A parameter array that was passed to a factory method (or) an empty object array otherwise.
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
- Specified by:
getAttribute
in 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:IAttributes
Set a custom attribute.- Specified by:
setAttribute
in interfaceIAttributes
-
getAttributeNames
public java.util.Set<java.lang.String> getAttributeNames()
- Specified by:
getAttributeNames
in interfaceIAttributes
- Returns:
- all the attributes names.
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.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(@Nonnull ITestResult comparison)
- Specified by:
compareTo
in interfacejava.lang.Comparable<ITestResult>
-
getInstanceName
public java.lang.String getInstanceName()
- Specified by:
getInstanceName
in interfaceITestResult
-
setTestName
public void setTestName(java.lang.String name)
- Specified by:
setTestName
in interfaceITestResult
- Parameters:
name
- - The new name to be used as a test name
-
getParameterIndex
public int getParameterIndex()
-
wasRetried
public boolean wasRetried()
- Specified by:
wasRetried
in interfaceITestResult
- Returns:
- -
true
if the test was retried again by an implementation ofIRetryAnalyzer
-
setWasRetried
public void setWasRetried(boolean wasRetried)
- Specified by:
setWasRetried
in interfaceITestResult
- Parameters:
wasRetried
- -true
if the test was retried andfalse
otherwise.
-
getSkipCausedBy
public java.util.List<ITestNGMethod> getSkipCausedBy()
- Specified by:
getSkipCausedBy
in interfaceITestResult
- Returns:
- - The list of either upstream method(s) or configuration method(s) whose failure led to the current method being skipped. An empty list is returned when the current method is not a skipped method.
-
-