Top Description Fields Constructors Methods
org.testng.internal

public Class TestResult

extends Object
implements ITestResult
Class Inheritance
All Implemented Interfaces
org.testng.ITestResult, java.lang.Comparable, org.testng.IAttributes
Imports
java.lang.reflect.InvocationTargetException, .Method, java.util.Arrays, .Collections, .List, .Set, .UUID, java.util.regex.Pattern, java.util.stream.Collectors, javax.annotation.Nonnull, org.testng.IAttributes, .IClass, .ITest, .ITestContext, .ITestNGMethod, .ITestResult, .Reporter, .TestNGException, org.testng.collections.Lists, .Objects

This class represents the result of a test.

Field Summary

Modifier and TypeField and Description
private final String
private 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>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private boolean
public int
compareTo(ITestResult
the object to be compared.
comparison
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.
public static void
public Object
getAttribute(String
The name of the attribute to return
name
)

Implements org.testng.IAttributes.getAttribute.

public Set<String>
public long

Returns:

Returns the endMillis.
getEndMillis
()

Implements org.testng.ITestResult.getEndMillis.

public Object[]
public String
public Object
public String
public ITestNGMethod

Returns:

Returns the method.
getMethod
()

Implements org.testng.ITestResult.getMethod.

public String
public int
public Object[]
public List<ITestNGMethod>
public long

Returns:

Returns the startMillis.
getStartMillis
()

Implements org.testng.ITestResult.getStartMillis.

public int

Returns:

Returns the status.
getStatus
()

Implements org.testng.ITestResult.getStatus.

public IClass

Returns:

Returns the testClass.
getTestClass
()

Implements org.testng.ITestResult.getTestClass.

public ITestContext
public String
getTestName()

Implements org.testng.ITestResult.getTestName.

If this result's related instance implements ITest or use @Test(testName=...), returns its test name, otherwise returns null.
public Throwable

Returns:

Returns the throwable.
getThrowable
()

Implements org.testng.ITestResult.getThrowable.

public String
private void
init(ITestNGMethod method, ITestContext ctx, Throwable t, long start, long end)

private static boolean
private boolean
public boolean
private static boolean
matches(List<String> upstreamMethods, ITestNGMethod method)

public static TestResult
public static TestResult
public static TestResult
public static TestResult
public static TestResult
newTestResultFrom(TestResult result, ITestNGMethod method, ITestContext ctx, long start)

public static TestResult
public Object
removeAttribute(String
The attribute name
name
)

Implements org.testng.IAttributes.removeAttribute.

Remove the attribute
public void
setAttribute(String
The attribute name
name
,
Object
The attribute value
value
)

Implements org.testng.IAttributes.setAttribute.

Set a custom attribute.
public void
public void
public void
public void
setMethod(ITestNGMethod
The method to set.
method
)

public void
setParameterIndex(int parameterIndex)

public void
public void
setStatus(int
The status to set.
status
)

Implements org.testng.ITestResult.setStatus.

public void
setTestName(String
- The new name to be used as a test name
name
)

Implements org.testng.ITestResult.setTestName.

public void
setThrowable(Throwable
The throwable to set.
throwable
)

Implements org.testng.ITestResult.setThrowable.

public void
setWasRetried(boolean
- true if the test was retried and false otherwise.
wasRetried
)

Implements org.testng.ITestResult.setWasRetried.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private static String
toString(int status)

public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

idback to summary
private final String id
m_attributesback to summary
private final IAttributes m_attributes
m_contextback to summary
private ITestContext m_context
m_endMillisback to summary
private long m_endMillis
m_hostback to summary
private String m_host
m_instanceNameback to summary
private String m_instanceName
m_methodback to summary
private ITestNGMethod m_method
m_nameback to summary
private String m_name
m_parametersback to summary
private Object[] m_parameters
m_startMillisback to summary
private long m_startMillis
m_statusback to summary
private int m_status
m_throwableback to summary
private Throwable m_throwable
m_wasRetriedback to summary
private boolean m_wasRetried
parameterIndexback to summary
private int parameterIndex
skipAnalysedback to summary
private boolean skipAnalysed
skippedDueToback to summary
private List<ITestNGMethod> skippedDueTo

Constructor Detail

TestResultback to summary
private TestResult()

Method Detail

belongToSameGroupback to summary
private boolean belongToSameGroup(ITestResult result)
compareToback to summary
public int compareTo(ITestResult comparison)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
comparison:ITestResult

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
copyAttributesback to summary
public static void copyAttributes(ITestResult source, ITestResult target)
getAttributeback to summary
public Object getAttribute(String name)

Implements org.testng.IAttributes.getAttribute.

Parameters
name:String

Doc from org.testng.IAttributes.getAttribute.

The name of the attribute to return

Returns:Object

Doc from org.testng.IAttributes.getAttribute.

The attribute

Annotations
@Override
getAttributeNamesback to summary
public Set<String> getAttributeNames()

Implements org.testng.IAttributes.getAttributeNames.

Returns:Set<String>

Doc from org.testng.IAttributes.getAttributeNames.

all the attributes names.

Annotations
@Override
getEndMillisback to summary
public long getEndMillis()

Implements org.testng.ITestResult.getEndMillis.

Returns:long

Returns the endMillis.

Annotations
@Override
getFactoryParametersback to summary
public Object[] getFactoryParameters()

Implements org.testng.ITestResult.getFactoryParameters.

Returns:Object[]

Doc from org.testng.ITestResult.getFactoryParameters.

- A parameter array that was passed to a factory method (or) an empty object array otherwise.

Annotations
@Override
getHostback to summary
public String getHost()

Implements org.testng.ITestResult.getHost.

Returns:String

Doc from org.testng.ITestResult.getHost.

The host where this suite was run, or null if it was run locally. The returned string has the form: host:port

Annotations
@Override
getInstanceback to summary
public Object getInstance()

Implements org.testng.ITestResult.getInstance.

Returns:Object

Doc from org.testng.ITestResult.getInstance.

The instance on which this method was run.

Annotations
@Override
getInstanceNameback to summary
public String getInstanceName()

Implements org.testng.ITestResult.getInstanceName.

Annotations
@Override
getMethodback to summary
public ITestNGMethod getMethod()

Implements org.testng.ITestResult.getMethod.

Returns:ITestNGMethod

Returns the method.

Annotations
@Override
getNameback to summary
public String getName()

Implements org.testng.ITestResult.getName.

Returns:String

Doc from org.testng.ITestResult.getName.

The name of this TestResult, typically identical to the name of the method.

Annotations
@Override
getParameterIndexback to summary
public int getParameterIndex()
getParametersback to summary
public Object[] getParameters()

Implements org.testng.ITestResult.getParameters.

Returns:Object[]

Doc from org.testng.ITestResult.getParameters.

The parameters this method was invoked with.

Annotations
@Override
getSkipCausedByback to summary
public List<ITestNGMethod> getSkipCausedBy()

Overrides default org.testng.ITestResult.getSkipCausedBy.

Returns:List<ITestNGMethod>

Doc from org.testng.ITestResult.getSkipCausedBy.

- 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.

getStartMillisback to summary
public long getStartMillis()

Implements org.testng.ITestResult.getStartMillis.

Returns:long

Returns the startMillis.

Annotations
@Override
getStatusback to summary
public int getStatus()

Implements org.testng.ITestResult.getStatus.

Returns:int

Returns the status.

Annotations
@Override
getTestClassback to summary
public IClass getTestClass()

Implements org.testng.ITestResult.getTestClass.

Returns:IClass

Returns the testClass.

Annotations
@Override
getTestContextback to summary
public ITestContext getTestContext()

Implements org.testng.ITestResult.getTestContext.

Returns:ITestContext

Doc from org.testng.ITestResult.getTestContext.

the ITestContext for this test result.

Annotations
@Override
getTestNameback to summary
public String getTestName()

Implements org.testng.ITestResult.getTestName.

If this result's related instance implements ITest or use @Test(testName=...), returns its test name, otherwise returns null.

Returns:String

Doc from org.testng.ITestResult.getTestName.

The test name if this result's related instance implements ITest or use @Test(testName=...), null otherwise.

Annotations
@Override
getThrowableback to summary
public Throwable getThrowable()

Implements org.testng.ITestResult.getThrowable.

Returns:Throwable

Returns the throwable.

Annotations
@Override
idback to summary
public String id()

Implements org.testng.ITestResult.id.

Returns:String

Doc from org.testng.ITestResult.id.

- A unique id for the current JVM that represents a unique way of identifying a specific test method's result.

initback to summary
private void init(ITestNGMethod method, ITestContext ctx, Throwable t, long start, long end)
isGlobalFailureback to summary
private static boolean isGlobalFailure(ITestResult result)
isRelatedback to summary
private boolean isRelated(ITestResult result)
isSuccessback to summary
public boolean isSuccess()

Implements org.testng.ITestResult.isSuccess.

Returns:boolean

Doc from org.testng.ITestResult.isSuccess.

true if if this test run is a SUCCESS

Annotations
@Override
matchesback to summary
private static boolean matches(List<String> upstreamMethods, ITestNGMethod method)
newContextAwareTestResultback to summary
public static TestResult newContextAwareTestResult(ITestNGMethod method, ITestContext ctx)
newEmptyTestResultback to summary
public static TestResult newEmptyTestResult()
newEndTimeAwareTestResultback to summary
public static TestResult newEndTimeAwareTestResult(ITestNGMethod method, ITestContext ctx, Throwable t, long start)
newTestResultForback to summary
public static TestResult newTestResultFor(ITestNGMethod method)
newTestResultFromback to summary
public static TestResult newTestResultFrom(TestResult result, ITestNGMethod method, ITestContext ctx, long start)
newTestResultWithCauseAsback to summary
public static TestResult newTestResultWithCauseAs(ITestNGMethod method, ITestContext ctx, Throwable t)
removeAttributeback to summary
public Object removeAttribute(String name)

Implements org.testng.IAttributes.removeAttribute.

Doc from org.testng.IAttributes.removeAttribute.

Remove the attribute

Parameters
name:String

The attribute name

Returns:Object

the attribute value if found, null otherwise

Annotations
@Override
setAttributeback to summary
public void setAttribute(String name, Object value)

Implements org.testng.IAttributes.setAttribute.

Doc from org.testng.IAttributes.setAttribute.

Set a custom attribute.

Parameters
name:String

The attribute name

value:Object

The attribute value

Annotations
@Override
setContextback to summary
public void setContext(ITestContext context)
setEndMillisback to summary
public void setEndMillis(long millis)

Implements org.testng.ITestResult.setEndMillis.

Annotations
@Override
setHostback to summary
public void setHost(String host)
setMethodback to summary
public void setMethod(ITestNGMethod method)
Parameters
method:ITestNGMethod

The method to set.

setParameterIndexback to summary
public void setParameterIndex(int parameterIndex)
setParametersback to summary
public void setParameters(Object[] parameters)

Implements org.testng.ITestResult.setParameters.

Annotations
@Override
setStatusback to summary
public void setStatus(int status)

Implements org.testng.ITestResult.setStatus.

Parameters
status:int

The status to set.

Annotations
@Override
setTestNameback to summary
public void setTestName(String name)

Implements org.testng.ITestResult.setTestName.

Parameters
name:String

Doc from org.testng.ITestResult.setTestName.

- The new name to be used as a test name

Annotations
@Override
setThrowableback to summary
public void setThrowable(Throwable throwable)

Implements org.testng.ITestResult.setThrowable.

Parameters
throwable:Throwable

The throwable to set.

Annotations
@Override
setWasRetriedback to summary
public void setWasRetried(boolean wasRetried)

Implements org.testng.ITestResult.setWasRetried.

Parameters
wasRetried:boolean

Doc from org.testng.ITestResult.setWasRetried.

- true if the test was retried and false otherwise.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
toStringback to summary
private static String toString(int status)
wasRetriedback to summary
public boolean wasRetried()

Implements org.testng.ITestResult.wasRetried.

Returns:boolean

Doc from org.testng.ITestResult.wasRetried.

- true if the test was retried again by an implementation of IRetryAnalyzer