Package org.testng.internal
Class TestResult
java.lang.Object
org.testng.internal.TestResult
- All Implemented Interfaces:
Comparable<ITestResult>
,IAttributes
,ITestResult
This class represents the result of a test.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final IAttributes
private ITestContext
private long
private String
private String
private ITestNGMethod
private String
private Object[]
private long
private int
private Throwable
private boolean
private int
private boolean
private List<ITestNGMethod>
Fields inherited from interface org.testng.ITestResult
CREATED, FAILURE, SKIP, STARTED, SUCCESS, SUCCESS_PERCENTAGE_FAILURE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
belongToSameGroup
(ITestResult result) int
compareTo
(ITestResult comparison) (package private) static void
copyAttributes
(ITestResult source, ITestResult target) getAttribute
(String name) long
Object[]
getHost()
getName()
int
Object[]
long
int
If this result's related instance implements ITest or use @Test(testName=...), returns its test name, otherwise returns null.private void
init
(ITestNGMethod method, ITestContext ctx, Throwable t, long start, long end) private static boolean
isGlobalFailure
(ITestResult result) private boolean
isRelated
(ITestResult result) boolean
static TestResult
newContextAwareTestResult
(ITestNGMethod method, ITestContext ctx) static TestResult
static TestResult
newEndTimeAwareTestResult
(ITestNGMethod method, ITestContext ctx, 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, Throwable t) removeAttribute
(String name) Remove the attributevoid
setAttribute
(String name, Object value) Set a custom attribute.void
setContext
(ITestContext context) void
setEndMillis
(long millis) void
void
setMethod
(ITestNGMethod method) (package private) void
setParameterIndex
(int parameterIndex) void
setParameters
(Object[] parameters) void
setStatus
(int status) void
setTestName
(String name) void
setThrowable
(Throwable throwable) void
setWasRetried
(boolean wasRetried) toString()
private static String
toString
(int status) boolean
-
Field Details
-
m_method
-
skippedDueTo
-
skipAnalysed
private boolean skipAnalysed -
m_status
private int m_status -
m_throwable
-
m_startMillis
private long m_startMillis -
m_endMillis
private long m_endMillis -
m_name
-
m_host
-
m_parameters
-
m_instanceName
-
m_context
-
parameterIndex
private int parameterIndex -
m_wasRetried
private boolean m_wasRetried -
m_attributes
-
-
Constructor Details
-
TestResult
private TestResult()
-
-
Method Details
-
newEmptyTestResult
-
newTestResultFor
-
newContextAwareTestResult
-
newTestResultWithCauseAs
public static TestResult newTestResultWithCauseAs(ITestNGMethod method, ITestContext ctx, Throwable t) -
newEndTimeAwareTestResult
public static TestResult newEndTimeAwareTestResult(ITestNGMethod method, ITestContext ctx, Throwable t, long start) -
newTestResultFrom
public static TestResult newTestResultFrom(TestResult result, ITestNGMethod method, ITestContext ctx, long start) -
init
-
setEndMillis
public void setEndMillis(long millis) - Specified by:
setEndMillis
in interfaceITestResult
-
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
- Returns:
- The test name if this result's related instance implements ITest or use @Test(testName=...), null otherwise.
-
getName
- Specified by:
getName
in interfaceITestResult
- Returns:
- The name of this TestResult, typically identical to the name of the method.
-
getMethod
- Specified by:
getMethod
in interfaceITestResult
- Returns:
- Returns the method.
-
setMethod
- 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
- Specified by:
getTestClass
in interfaceITestResult
- Returns:
- Returns the testClass.
-
getThrowable
- Specified by:
getThrowable
in interfaceITestResult
- Returns:
- Returns the throwable.
-
setThrowable
- 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
-
toString
-
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
-
getParameters
- Specified by:
getParameters
in interfaceITestResult
- Returns:
- The parameters this method was invoked with.
-
setParameters
- Specified by:
setParameters
in interfaceITestResult
-
getInstance
- Specified by:
getInstance
in interfaceITestResult
- Returns:
- The instance on which this method was run.
-
getFactoryParameters
- Specified by:
getFactoryParameters
in interfaceITestResult
- Returns:
- - A parameter array that was passed to a factory method (or) an empty object array otherwise.
-
getAttribute
- Specified by:
getAttribute
in interfaceIAttributes
- Parameters:
name
- The name of the attribute to return- Returns:
- The attribute
-
setAttribute
Description copied from interface:IAttributes
Set a custom attribute.- Specified by:
setAttribute
in interfaceIAttributes
- Parameters:
name
- The attribute namevalue
- The attribute value
-
getAttributeNames
- Specified by:
getAttributeNames
in interfaceIAttributes
- Returns:
- all the attributes names.
-
removeAttribute
Description copied from interface:IAttributes
Remove the attribute- Specified by:
removeAttribute
in interfaceIAttributes
- Parameters:
name
- The attribute name- Returns:
- the attribute value if found, null otherwise
-
getTestContext
- Specified by:
getTestContext
in interfaceITestResult
- Returns:
- the
ITestContext
for this test result.
-
setContext
-
compareTo
- Specified by:
compareTo
in interfaceComparable<ITestResult>
-
getInstanceName
- Specified by:
getInstanceName
in interfaceITestResult
-
setTestName
- Specified by:
setTestName
in interfaceITestResult
- Parameters:
name
- - The new name to be used as a test name
-
setParameterIndex
void setParameterIndex(int parameterIndex) -
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
- 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.
-
isGlobalFailure
-
isRelated
-
belongToSameGroup
-
copyAttributes
-