Package hudson.tasks.junit
Class TestResult
- All Implemented Interfaces:
ModelObject
,SearchableModelObject
,SearchItem
,Serializable
Root of all the test results for one build.
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Field Summary
FieldsFields inherited from class hudson.tasks.test.TabulatedResult
testsByBlock
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty result.TestResult
(boolean keepLongStdio) Deprecated.TestResult
(long buildTime, boolean keepLongStdio) Deprecated.TestResult
(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results) Deprecated.TestResult
(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results, boolean keepLongStdio) Deprecated.TestResult
(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results, boolean keepLongStdio, boolean keepProperties, boolean keepTestNames, PipelineTestDetails pipelineTestDetails, boolean skipOldReports) Deprecated.TestResult
(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results, boolean keepLongStdio, boolean keepProperties, PipelineTestDetails pipelineTestDetails, boolean skipOldReports) Deprecated.TestResult
(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results, boolean keepLongStdio, PipelineTestDetails pipelineTestDetails) Deprecated.TestResult
(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results, StdioRetention stdioRetention, boolean keepProperties, boolean keepTestNames, PipelineTestDetails pipelineTestDetails, boolean skipOldReports) Collect reports from the givenDirectoryScanner
, while filtering out all files that were created before the given time.TestResult
(TestResult src) TestResult
(TestResultImpl impl) -
Method Summary
Modifier and TypeMethodDescriptionblockToTestResult
(PipelineBlockWithTests block, TabulatedResult fullResult) Get an aggregatedTestResult
for all test results in aPipelineBlockWithTests
and any children it may have.Find the test result corresponding to the one identified byid
within this test result.void
freeze
(TestResultAction parent) Builds up the transient part of the data structure from resultsparsed
so far.Gets the child test result objects.Get a simple name for the type of children theTabulatedResult.getChildren()
method returns, for example "case", "class" or "package".float
Time it took to run this test.getDynamic
(String token, org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) If there was an error or a failure, this is the text from the message.If there was an error or a failure, this is the stack trace, or otherwise null.int
Gets the total number of failed tests.int
If this test failed, then return the build number when this test started failing.Run<?,
?> If this test failed, then return the run when this test started failing.All failed tests.getName()
Gets the name of this object.Reverse pointer ofTabulatedResult.getChildren()
.Returns the action that points to the top level test result includes this test result.int
Gets the total number of passed tests.Gets the "children" of this test result that passedGets the counter part of thisTestResult
in the previous run.getResultByNode
(String nodeId) getResultByNodes
(List<String> nodeIds) getResultForPipelineBlock
(String blockId) Run<?,
?> getRun()
int
Gets the total number of skipped tests.Gets the "children" of this test result that were skippedlong
The stderr of this test.The stdout of this test.Returns the first suite with the given name.Returns all suites with the given name.Returns the top level test result data.getTitle()
Gets the human readable title of this result object.int
Gets the total number of tests.boolean
Whether this test result has children.boolean
isEmpty()
Returnstrue
if this doesn't have any any test results.boolean
isPassed()
boolean
void
parse
(long filesTimestamp, File baseDir, PipelineTestDetails pipelineTestDetails, String[] reportFiles) Collect reports from the given report files, while filtering out all files that were created before the given time.void
Deprecated.void
Deprecated.void
parse
(long filesTimestamp, Iterable<File> reportFiles, PipelineTestDetails pipelineTestDetails) Collect reports from the given report filesvoid
parse
(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results) Deprecated.void
parse
(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results, PipelineTestDetails pipelineTestDetails) Collect reports from the givenDirectoryScanner
, while filtering out all files that were created before the given time.void
Deprecated.void
parse
(File reportFile, PipelineTestDetails pipelineTestDetails) Parses an additional report file.void
parse
(Iterable<File> reportFiles, PipelineTestDetails pipelineTestDetails) Deprecated.void
setParent
(TestObject parent) Sets the parent test resultvoid
If the concept of a parent action is important to a subclass, then it should provide a non-noop implementation of this method.void
setSkipOldReports
(boolean skipOldReports) void
setStartTime
(long start) void
tally()
Recount my children.Methods inherited from class hudson.tasks.test.TabulatedResult
getPipelineBlockWithTests, hasMultipleBlocks, populateBlocks
Methods inherited from class hudson.tasks.test.TestResult
annotate, getBuildResult, getResultInRun, toPrettyString
Methods inherited from class hudson.tasks.test.TestObject
doSubmitDescription, getApi, getDescription, getDurationString, getFullDisplayName, getFullName, getHistory, getId, getRelativePathFrom, getResultInBuild, getSafeName, getSearchUrl, getTestAction, getTestActions, getTestResultAction, getTopLevelTestResult, 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
-
Field Details
-
FILE_TIME_PRECISION_MARGIN
public static final long FILE_TIME_PRECISION_MARGIN
-
-
Constructor Details
-
TestResult
public TestResult()Creates an empty result. -
TestResult
Deprecated.- Since:
- 1.522
-
TestResult
Deprecated.- Throws:
IOException
-
TestResult
@Deprecated public TestResult(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results) throws IOException Deprecated.- Throws:
IOException
-
TestResult
@Deprecated public TestResult(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results, boolean keepLongStdio) throws IOException Deprecated.- Throws:
IOException
-
TestResult
@Deprecated public TestResult(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results, boolean keepLongStdio, PipelineTestDetails pipelineTestDetails) throws IOException Deprecated.- Throws:
IOException
-
TestResult
@Deprecated public TestResult(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results, boolean keepLongStdio, boolean keepProperties, PipelineTestDetails pipelineTestDetails, boolean skipOldReports) throws IOException Deprecated.Collect reports from the givenDirectoryScanner
, while filtering out all files that were created before the given time.- Parameters:
filesTimestamp
- per default files older than this will be ignored (depending on param skipOldReports)keepLongStdio
- if true, retain a suite's complete stdout/stderr even if this is huge and the suite passedpipelineTestDetails
- APipelineTestDetails
instance containing Pipeline-related additional arguments.skipOldReports
- to parse or not test files older than filesTimestamp- Throws:
IOException
- Since:
- 1.22
-
TestResult
@Deprecated public TestResult(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results, boolean keepLongStdio, boolean keepProperties, boolean keepTestNames, PipelineTestDetails pipelineTestDetails, boolean skipOldReports) throws IOException Deprecated.- Throws:
IOException
-
TestResult
public TestResult(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results, StdioRetention stdioRetention, boolean keepProperties, boolean keepTestNames, PipelineTestDetails pipelineTestDetails, boolean skipOldReports) throws IOException Collect reports from the givenDirectoryScanner
, while filtering out all files that were created before the given time.- Parameters:
filesTimestamp
- per default files older than this will be ignored (depending on param skipOldReports)stdioRetention
- how to retain stdout/stderr for large outputskeepProperties
- to keep properties or notkeepTestNames
- to prepend parallel test stage to test name or notpipelineTestDetails
- APipelineTestDetails
instance containing Pipeline-related additional arguments.skipOldReports
- to parse or not test files older than filesTimestamp- Throws:
IOException
-
TestResult
-
TestResult
-
-
Method Details
-
getPluggableStorage
-
getParent
Description copied from class:TestObject
Reverse pointer ofTabulatedResult.getChildren()
.- Specified by:
getParent
in classTestObject
- Returns:
- the parent
TestObject
.
-
setParent
Description copied from class:TestResult
Sets the parent test result- Overrides:
setParent
in classTestResult
- Parameters:
parent
- Parent test result.
-
getTestResult
Description copied from class:TestObject
Returns the top level test result data.- Overrides:
getTestResult
in classTestObject
-
parse
@Deprecated public void parse(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results) throws IOException Deprecated.- Throws:
IOException
-
parse
public void parse(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results, PipelineTestDetails pipelineTestDetails) throws IOException Collect reports from the givenDirectoryScanner
, while filtering out all files that were created before the given time.- Parameters:
filesTimestamp
- file timestamp to filter files older.results
- Directory scanner.pipelineTestDetails
- APipelineTestDetails
instance containing Pipeline-related additional arguments.- Throws:
IOException
- if an error occurs.- Since:
- 1.22
-
parse
@Deprecated public void parse(long filesTimestamp, File baseDir, String[] reportFiles) throws IOException Deprecated.- Throws:
IOException
-
parse
public void parse(long filesTimestamp, File baseDir, PipelineTestDetails pipelineTestDetails, String[] reportFiles) throws IOException Collect reports from the given report files, while filtering out all files that were created before the given time.- Parameters:
filesTimestamp
- file timestamp to filter files older.baseDir
- Base directory.pipelineTestDetails
- APipelineTestDetails
instance containing Pipeline-related additional arguments.reportFiles
- Report files.- Throws:
IOException
- if an error occurs.- Since:
- 1.22
-
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.
-
parse
Deprecated.- Throws:
IOException
-
parse
public void parse(long filesTimestamp, Iterable<File> reportFiles, PipelineTestDetails pipelineTestDetails) throws IOException Collect reports from the given report files- Parameters:
filesTimestamp
- Build time.reportFiles
- Report files.pipelineTestDetails
- APipelineTestDetails
instance containing Pipeline-related additional arguments.- Throws:
IOException
- if an error occurs.- Since:
- 1.22
-
parse
@Deprecated public void parse(Iterable<File> reportFiles, PipelineTestDetails pipelineTestDetails) throws IOException Deprecated.Collect reports from the given report files- Parameters:
reportFiles
- Report files.pipelineTestDetails
- APipelineTestDetails
instance containing Pipeline-related additional arguments.- Throws:
IOException
- if an error occurs.
-
parse
Deprecated.- Throws:
IOException
-
parse
Parses an additional report file.- Parameters:
reportFile
- Report file to parse.pipelineTestDetails
- APipelineTestDetails
instance containing Pipeline-related additional arguments.- Throws:
IOException
- if an error occurs.- Since:
- 1.22
-
getDisplayName
-
getRun
- Overrides:
getRun
in classTestObject
- Returns:
- the run in which this test was executed.
-
findCorrespondingResult
Description copied from class:TestObject
Find the test result corresponding to the one identified byid
within this test result.- Specified by:
findCorrespondingResult
in classTestObject
- Parameters:
id
- The path to the original test result- Returns:
- A corresponding test result, or null if there is no corresponding result.
-
getTitle
Description copied from class:TestResult
Gets the human readable title of this result object.- Overrides:
getTitle
in classTestResult
- Returns:
- the human readable title of this result object.
-
getChildTitle
- Overrides:
getChildTitle
in classTabulatedResult
-
getChildType
Description copied from class:TabulatedResult
Get a simple name for the type of children theTabulatedResult.getChildren()
method returns, for example "case", "class" or "package".- Overrides:
getChildType
in classTabulatedResult
- Returns:
- the type of children this result has, all lowercase.
-
getDuration
@Exported(visibility=999) public float getDuration()Description copied from class:TestResult
Time it took to run this test. In seconds.- Overrides:
getDuration
in classTestResult
- Returns:
- the time in seconds the test ran.
-
setStartTime
public void setStartTime(long start) -
getStartTime
public long getStartTime() -
getPassCount
@Exported(visibility=999) 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.
-
getFailCount
@Exported(visibility=999) 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
@Exported(visibility=999) 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.
-
getTotalCount
public int getTotalCount()Description copied from class:TestObject
Gets the total number of tests.- Overrides:
getTotalCount
in classTestObject
- Returns:
- the total number of tests.
-
isEmpty
@Exported(visibility=999) public boolean isEmpty()Returnstrue
if this doesn't have any any test results.- Returns:
- whether this doesn't contain any test results.
- Since:
- 1.511
-
getFailedTests
Description copied from class:MetaTabulatedResult
All failed tests.- Specified by:
getFailedTests
in classMetaTabulatedResult
- Returns:
- the children of this test result, if any, or an empty collection
-
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
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
-
getFailedSince
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
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.
-
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 fromSuiteResult.getStdout()
.- Overrides:
getStdout
in classTestResult
- Returns:
- the stdout of this test.
- Since:
- 1.294
-
getStderr
The stderr of this test.- Overrides:
getStderr
in classTestResult
- Returns:
- the stderr of this test.
- Since:
- 1.294
- See Also:
-
getProperties
- Overrides:
getProperties
in classTestResult
-
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
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.
-
isPassed
public boolean isPassed()- Overrides:
isPassed
in classTestResult
- Returns:
- true if the test was not skipped and did not fail, false otherwise.
-
getChildren
Description copied from class:TabulatedResult
Gets the child test result objects.- Specified by:
getChildren
in classTabulatedResult
- Returns:
- the child test result objects.
- See Also:
-
hasChildren
public boolean hasChildren()Whether this test result has children.- Specified by:
hasChildren
in classTabulatedResult
-
getSuites
-
getName
Description copied from class:TestObject
Gets the name of this object.- Overrides:
getName
in classTestObject
- Returns:
- the name of this object.
-
getDynamic
public Object getDynamic(String token, org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) - Overrides:
getDynamic
in classTestObject
-
byPackage
-
getSuite
Returns the first suite with the given name. Prefer usinggetSuites(String)
to disambiguate suites with the same name.- Parameters:
name
- the suite name- Returns:
- The first test suite with the given name, or null if not found.
-
getSuites
Returns all suites with the given name.- Parameters:
name
- the suite name- Returns:
- all suites with the given name
-
getResultByNode
-
getResultByNodes
-
setParentAction
Description copied from class:TestResult
If the concept of a parent action is important to a subclass, then it should provide a non-noop implementation of this method.- Overrides:
setParentAction
in classTestResult
- Parameters:
action
- Action that points to the top level test result.
-
getParentAction
Description copied from class:TestResult
Returns the action that points to the top level test result includes this test result.- Overrides:
getParentAction
in classTestResult
- Returns:
- action The action that points to the top level test result.
-
tally
public void tally()Recount my children.- Overrides:
tally
in classTestResult
-
freeze
Builds up the transient part of the data structure from resultsparsed
so far.After the data is frozen, more files can be parsed and then freeze can be called again.
-
getResultForPipelineBlock
-
isSkipOldReports
public boolean isSkipOldReports() -
setSkipOldReports
public void setSkipOldReports(boolean skipOldReports) -
blockToTestResult
@NonNull public TabulatedResult blockToTestResult(@NonNull PipelineBlockWithTests block, @NonNull TabulatedResult fullResult) Get an aggregatedTestResult
for all test results in aPipelineBlockWithTests
and any children it may have.- Overrides:
blockToTestResult
in classTabulatedResult
-
getCase
-
parse(long, Iterable, PipelineTestDetails)