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 aggregatedTestResultfor all test results in aPipelineBlockWithTestsand any children it may have.Find the test result corresponding to the one identified byidwithin this test result.voidfreeze(TestResultAction parent) Builds up the transient part of the data structure from resultsparsedso 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".floatTime it took to run this test.getDynamic(String token, org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 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.intGets the total number of failed tests.intIf 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.intGets the total number of passed tests.Gets the "children" of this test result that passedGets the counter part of thisTestResultin the previous run.io.jenkins.plugins.prism.PrismConfigurationgetResultByNode(String nodeId) getResultByNodes(List<String> nodeIds) getResultForPipelineBlock(String blockId) Run<?, ?> getRun()intGets the total number of skipped tests.Gets the "children" of this test result that were skippedlongThe 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.intGets the total number of tests.booleanWhether this test result has children.booleanisEmpty()Returnstrueif this doesn't have any any test results.booleanisPassed()booleanvoidparse(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.voidDeprecated.voidDeprecated.voidparse(long filesTimestamp, Iterable<File> reportFiles, PipelineTestDetails pipelineTestDetails) Collect reports from the given report filesvoidparse(long filesTimestamp, org.apache.tools.ant.DirectoryScanner results) Deprecated.voidparse(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.voidDeprecated.voidparse(File reportFile, PipelineTestDetails pipelineTestDetails) Parses an additional report file.voidparse(Iterable<File> reportFiles, PipelineTestDetails pipelineTestDetails) Deprecated.voidsetParent(TestObject parent) Sets the parent test resultvoidIf the concept of a parent action is important to a subclass, then it should provide a non-noop implementation of this method.voidsetSkipOldReports(boolean skipOldReports) voidsetStartTime(long start) voidtally()Recount my children.Methods inherited from class hudson.tasks.test.TabulatedResult
getPipelineBlockWithTests, hasMultipleBlocks, populateBlocksMethods inherited from class hudson.tasks.test.TestResult
annotate, getBuildResult, getFlakyFailures, getRerunFailures, getResultInRun, toPrettyStringMethods 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, uniquifyNameMethods inherited from class hudson.tasks.junit.TestObject
getOwnerMethods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError, sendError, sendError, sendErrorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface hudson.search.SearchItem
getSearchGroup, getSearchIcon
-
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- APipelineTestDetailsinstance 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- APipelineTestDetailsinstance 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:TestObjectReverse pointer ofTabulatedResult.getChildren().- Specified by:
getParentin classTestObject- Returns:
- the parent
TestObject.
-
setParent
Description copied from class:TestResultSets the parent test result- Overrides:
setParentin classTestResult- Parameters:
parent- Parent test result.
-
getTestResult
Description copied from class:TestObjectReturns the top level test result data.- Overrides:
getTestResultin 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- APipelineTestDetailsinstance 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- APipelineTestDetailsinstance containing Pipeline-related additional arguments.reportFiles- Report files.- Throws:
IOException- if an error occurs.- Since:
- 1.22
-
getPreviousResult
Description copied from class:TestResultGets the counter part of thisTestResultin the previous run.- Overrides:
getPreviousResultin 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- APipelineTestDetailsinstance 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- APipelineTestDetailsinstance 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- APipelineTestDetailsinstance containing Pipeline-related additional arguments.- Throws:
IOException- if an error occurs.- Since:
- 1.22
-
getDisplayName
-
getRun
- Overrides:
getRunin classTestObject- Returns:
- the run in which this test was executed.
-
findCorrespondingResult
Description copied from class:TestObjectFind the test result corresponding to the one identified byidwithin this test result.- Specified by:
findCorrespondingResultin 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:TestResultGets the human readable title of this result object.- Overrides:
getTitlein classTestResult- Returns:
- the human readable title of this result object.
-
getChildTitle
- Overrides:
getChildTitlein classTabulatedResult
-
getChildType
Description copied from class:TabulatedResultGet a simple name for the type of children theTabulatedResult.getChildren()method returns, for example "case", "class" or "package".- Overrides:
getChildTypein classTabulatedResult- Returns:
- the type of children this result has, all lowercase.
-
getDuration
@Exported(visibility=999) public float getDuration()Description copied from class:TestResultTime it took to run this test. In seconds.- Overrides:
getDurationin 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:TestResultGets the total number of passed tests.- Overrides:
getPassCountin classTestResult- Returns:
- the total number of passed tests.
-
getFailCount
@Exported(visibility=999) public int getFailCount()Description copied from class:TestResultGets the total number of failed tests.- Overrides:
getFailCountin classTestResult- Returns:
- the total number of failed tests.
-
getSkipCount
@Exported(visibility=999) public int getSkipCount()Description copied from class:TestResultGets the total number of skipped tests.- Overrides:
getSkipCountin classTestResult- Returns:
- the total number of skipped tests.
-
getTotalCount
public int getTotalCount()Description copied from class:TestObjectGets the total number of tests.- Overrides:
getTotalCountin classTestObject- Returns:
- the total number of tests.
-
isEmpty
@Exported(visibility=999) public boolean isEmpty()Returnstrueif 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:MetaTabulatedResultAll failed tests.- Specified by:
getFailedTestsin 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:
getPassedTestsin 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:
getSkippedTestsin 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:
getFailedSincein 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:
getFailedSinceRunin 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:
getStdoutin classTestResult- Returns:
- the stdout of this test.
- Since:
- 1.294
-
getStderr
The stderr of this test.- Overrides:
getStderrin classTestResult- Returns:
- the stderr of this test.
- Since:
- 1.294
- See Also:
-
getProperties
- Overrides:
getPropertiesin classTestResult
-
getErrorStackTrace
If there was an error or a failure, this is the stack trace, or otherwise null.- Overrides:
getErrorStackTracein 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:
getErrorDetailsin classTestResult- Returns:
- the message of the error or failure.
-
isPassed
public boolean isPassed()- Overrides:
isPassedin classTestResult- Returns:
- true if the test was not skipped and did not fail, false otherwise.
-
getChildren
Description copied from class:TabulatedResultGets the child test result objects.- Specified by:
getChildrenin classTabulatedResult- Returns:
- the child test result objects.
- See Also:
-
hasChildren
public boolean hasChildren()Whether this test result has children.- Specified by:
hasChildrenin classTabulatedResult
-
getSuites
-
getName
Description copied from class:TestObjectGets the name of this object.- Overrides:
getNamein classTestObject- Returns:
- the name of this object.
-
getDynamic
public Object getDynamic(String token, org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) - Overrides:
getDynamicin 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:TestResultIf the concept of a parent action is important to a subclass, then it should provide a non-noop implementation of this method.- Overrides:
setParentActionin classTestResult- Parameters:
action- Action that points to the top level test result.
-
getParentAction
Description copied from class:TestResultReturns the action that points to the top level test result includes this test result.- Overrides:
getParentActionin classTestResult- Returns:
- action The action that points to the top level test result.
-
tally
public void tally()Recount my children.- Overrides:
tallyin classTestResult
-
freeze
Builds up the transient part of the data structure from resultsparsedso 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 aggregatedTestResultfor all test results in aPipelineBlockWithTestsand any children it may have.- Overrides:
blockToTestResultin classTabulatedResult
-
getCase
-
getPrismConfiguration
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public io.jenkins.plugins.prism.PrismConfiguration getPrismConfiguration()
-
parse(long, Iterable, PipelineTestDetails)