Package hudson.tasks.junit
Class CaseResult
- java.lang.Object
-
- hudson.model.AbstractModelObject
-
- hudson.tasks.junit.TestObject
-
- hudson.tasks.test.TestObject
-
- hudson.tasks.test.TestResult
-
- hudson.tasks.junit.CaseResult
-
- All Implemented Interfaces:
ModelObject
,SearchableModelObject
,SearchItem
,Serializable
,Comparable<CaseResult>
public class CaseResult extends TestResult implements Comparable<CaseResult>
One test result. Non-final since 1.526- Author:
- Kohsuke Kawaguchi
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CaseResult.Status
Constants that represent the status of this test.
-
Constructor Summary
Constructors Constructor Description CaseResult(SuiteResult parent, String testName, String errorStackTrace)
Used to create a fake failure, when Hudson fails to load data from XML files.CaseResult(SuiteResult parent, String testName, String errorStackTrace, String errorDetails)
CaseResult(SuiteResult parent, String className, String testName, String errorDetails, String skippedMessage, float duration, String stdout, String stderr, String stacktrace)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(CaseResult that)
boolean
equals(Object obj)
TestResult
findCorrespondingResult(String id)
Case results have no childrenvoid
freeze(SuiteResult parent)
int
getAge()
Gets the number of consecutive builds (including this) that this test case has been failing.String
getClassName()
Gets the class name of a test class.String
getDisplayName()
float
getDuration()
Gets the duration of the test, in secondsList<String>
getEnclosingFlowNodeIds()
List<String>
getEnclosingFlowNodeNames()
String
getErrorDetails()
If there was an error or a failure, this is the text from the message.String
getErrorStackTrace()
If there was an error or a failure, this is the stack trace, or otherwise null.int
getFailCount()
Gets the total number of failed tests.int
getFailedSince()
If this test failed, then return the build number when this test started failing.Run<?,?>
getFailedSinceRun()
If this test failed, then return the run when this test started failing.Collection<? extends TestResult>
getFailedTests()
Gets the "children" of this test result that failedString
getFlowNodeId()
String
getFullDisplayName()
String
getFullName()
Gets the full name of this object.String
getName()
Gets the name of the test, which is returned fromTestCase.getName()
String
getPackageName()
Gets the package name of a test case.ClassResult
getParent()
Reverse pointer ofTabulatedResult.getChildren()
.int
getPassCount()
Gets the total number of passed tests.Collection<? extends TestResult>
getPassedTests()
Gets the "children" of this test result that passedCaseResult
getPreviousResult()
Gets the counter part of thisTestResult
in the previous run.Map<String,String>
getProperties()
Run<?,?>
getRun()
String
getSafeName()
Gets the version ofgetName()
that's URL-safe.String
getSimpleName()
Gets the simple (not qualified) class name.int
getSkipCount()
Gets the total number of skipped tests.String
getSkippedMessage()
Provides the reason given for the test being being skipped.Collection<? extends TestResult>
getSkippedTests()
Gets the "children" of this test result that were skippedCaseResult.Status
getStatus()
String
getStderr()
The stderr of this test.String
getStdout()
The stdout of this test.SuiteResult
getSuiteResult()
String
getTitle()
Gets the human readable title of this result object.String
getTransformedFullDisplayName()
String
getTransformedTestName()
int
hashCode()
boolean
isFailed()
boolean
isPassed()
boolean
isSkipped()
Tests whether the test was skipped or not.void
setClass(ClassResult classResult)
void
setParentSuiteResult(SuiteResult parent)
-
Methods inherited from class hudson.tasks.test.TestResult
annotate, getBuildResult, getParentAction, getResultInRun, setParent, setParentAction, tally, toPrettyString
-
Methods inherited from class hudson.tasks.test.TestObject
doSubmitDescription, getApi, getDescription, getDurationString, getDynamic, getHistory, getId, getRelativePathFrom, getResultInBuild, getSearchUrl, getTestAction, getTestActions, getTestResult, getTestResultAction, getTopLevelTestResult, getTotalCount, getUrl, safe, setDescription, uniquifyName
-
Methods inherited from class hudson.tasks.junit.TestObject
getOwner
-
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
-
-
-
-
Constructor Detail
-
CaseResult
public CaseResult(SuiteResult parent, String testName, String errorStackTrace)
Used to create a fake failure, when Hudson fails to load data from XML files. Public since 1.526.- Parameters:
parent
- Parent result.testName
- Test name.errorStackTrace
- Error stack trace.
-
CaseResult
public CaseResult(SuiteResult parent, String testName, String errorStackTrace, String errorDetails)
-
-
Method Detail
-
getParent
public ClassResult getParent()
Description copied from class:TestObject
Reverse pointer ofTabulatedResult.getChildren()
.- Specified by:
getParent
in classTestObject
- Returns:
- the parent
TestObject
.
-
getTransformedTestName
public String getTransformedTestName()
-
getDisplayName
public String getDisplayName()
- Specified by:
getDisplayName
in interfaceModelObject
-
getName
@Exported(visibility=999) public String getName()
Gets the name of the test, which is returned fromTestCase.getName()
Note that this may contain any URL-unfriendly character.
- Overrides:
getName
in classTestObject
- Returns:
- the name of this object.
-
getTitle
public String getTitle()
Gets the human readable title of this result object.- Overrides:
getTitle
in classTestResult
- Returns:
- the human readable title of this result object.
-
getDuration
@Exported(visibility=9) public float getDuration()
Gets the duration of the test, in seconds- Overrides:
getDuration
in classTestResult
- Returns:
- the time in seconds the test ran.
-
getSafeName
public String getSafeName()
Gets the version ofgetName()
that's URL-safe.- Overrides:
getSafeName
in classTestObject
- Returns:
- the URL-safe name of this object.
-
getClassName
@Exported(visibility=9) public String getClassName()
Gets the class name of a test class.- Returns:
- the class name of a test class.
-
getSimpleName
public String getSimpleName()
Gets the simple (not qualified) class name.- Returns:
- the simple (not qualified) class name.
-
getPackageName
public String getPackageName()
Gets the package name of a test case.- Returns:
- the package name of a test case.
-
getFullName
public String getFullName()
Description copied from class:TestObject
Gets the full name of this object.- Overrides:
getFullName
in classTestObject
- Returns:
- the full name of this object.
-
getFullDisplayName
public String getFullDisplayName()
- Overrides:
getFullDisplayName
in classTestObject
- Since:
- 1.515
-
getTransformedFullDisplayName
public String getTransformedFullDisplayName()
-
getFailCount
public int getFailCount()
Description copied from class:TestResult
Gets the total number of failed tests.- Overrides:
getFailCount
in classTestResult
- Returns:
- the total number of failed tests.
-
getSkipCount
public int getSkipCount()
Description copied from class:TestResult
Gets the total number of skipped tests.- Overrides:
getSkipCount
in classTestResult
- Returns:
- the total number of skipped tests.
-
getPassCount
public int getPassCount()
Description copied from class:TestResult
Gets the total number of passed tests.- Overrides:
getPassCount
in classTestResult
- Returns:
- the total number of passed tests.
-
getFailedSince
@Exported(visibility=9) public int getFailedSince()
If this test failed, then return the build number when this test started failing.- Overrides:
getFailedSince
in classTestResult
- Returns:
- the build number when this test started failing.
-
getFailedSinceRun
public Run<?,?> getFailedSinceRun()
Description copied from class:TestResult
If this test failed, then return the run when this test started failing.- Overrides:
getFailedSinceRun
in classTestResult
- Returns:
- the run when this test started failing.
-
getAge
@Exported(visibility=9) public int getAge()
Gets the number of consecutive builds (including this) that this test case has been failing.- Returns:
- the number of consecutive failing builds.
-
getStdout
@Exported public String getStdout()
The stdout of this test.Depending on the tool that produced the XML report, this method works somewhat inconsistently. With some tools (such as Maven surefire plugin), you get the accurate information, that is the stdout from this test case. With some other tools (such as the JUnit task in Ant), this method returns the stdout produced by the entire test suite.
If you need to know which is the case, compare this output from
SuiteResult.getStdout()
.- Overrides:
getStdout
in classTestResult
- Returns:
- the stdout of this test.
- Since:
- 1.294
-
getStderr
@Exported public String getStderr()
The stderr of this test.- Overrides:
getStderr
in classTestResult
- Returns:
- the stderr of this test.
- Since:
- 1.294
- See Also:
getStdout()
-
getPreviousResult
public CaseResult getPreviousResult()
Description copied from class:TestResult
Gets the counter part of thisTestResult
in the previous run.- Overrides:
getPreviousResult
in classTestResult
- Returns:
- null if no such counter part exists.
-
findCorrespondingResult
public TestResult findCorrespondingResult(String id)
Case results have no children- Specified by:
findCorrespondingResult
in classTestObject
- Parameters:
id
- The path to the original test result- Returns:
- null
-
getFailedTests
public Collection<? extends TestResult> getFailedTests()
Gets the "children" of this test result that failed- Overrides:
getFailedTests
in classTestResult
- Returns:
- the children of this test result, if any, or an empty collection
-
getPassedTests
public Collection<? extends TestResult> getPassedTests()
Gets the "children" of this test result that passed- Overrides:
getPassedTests
in classTestResult
- Returns:
- the children of this test result, if any, or an empty collection
-
getSkippedTests
public Collection<? extends TestResult> getSkippedTests()
Gets the "children" of this test result that were skipped- Overrides:
getSkippedTests
in classTestResult
- Returns:
- the children of this test result, if any, or an empty list
-
getErrorStackTrace
@Exported public String getErrorStackTrace()
If there was an error or a failure, this is the stack trace, or otherwise null.- Overrides:
getErrorStackTrace
in classTestResult
- Returns:
- the stack trace of the error or failure.
-
getErrorDetails
@Exported public String getErrorDetails()
If there was an error or a failure, this is the text from the message.- Overrides:
getErrorDetails
in classTestResult
- Returns:
- the message of the error or failure.
-
getProperties
@Exported public Map<String,String> getProperties()
- Overrides:
getProperties
in classTestResult
-
isPassed
public boolean isPassed()
- Overrides:
isPassed
in classTestResult
- Returns:
- true if the test was not skipped and did not fail, false otherwise.
-
isSkipped
@Exported(visibility=9) public boolean isSkipped()
Tests whether the test was skipped or not. TestNG allows tests to be skipped if their dependencies fail or they are part of a group that has been configured to be skipped.- Returns:
- true if the test was not executed, false otherwise.
-
isFailed
public boolean isFailed()
- Returns:
- true if the test was not skipped and did not pass, false otherwise.
- Since:
- 1.520
-
getSkippedMessage
@Exported public String getSkippedMessage()
Provides the reason given for the test being being skipped.- Returns:
- the message given for a skipped test if one has been provided, null otherwise.
- Since:
- 1.507
-
getSuiteResult
public SuiteResult getSuiteResult()
-
getFlowNodeId
@CheckForNull public String getFlowNodeId()
-
getRun
public Run<?,?> getRun()
- Overrides:
getRun
in classTestObject
- Returns:
- the run in which this test was executed.
-
setParentSuiteResult
public void setParentSuiteResult(SuiteResult parent)
-
freeze
public void freeze(SuiteResult parent)
-
compareTo
public int compareTo(CaseResult that)
- Specified by:
compareTo
in interfaceComparable<CaseResult>
-
getStatus
@Exported(name="status", visibility=9) public CaseResult.Status getStatus()
-
setClass
public void setClass(ClassResult classResult)
-
-