Class TestResult

All Implemented Interfaces:
ModelObject, SearchableModelObject, SearchItem, Serializable

public final class TestResult extends MetaTabulatedResult
Root of all the test results for one build.
Author:
Kohsuke Kawaguchi
See Also:
  • 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 public TestResult(boolean keepLongStdio)
      Deprecated.
      Since:
      1.522
    • TestResult

      @Deprecated public TestResult(long buildTime, boolean keepLongStdio) throws IOException
      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 given DirectoryScanner, 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 passed
      pipelineTestDetails - A PipelineTestDetails 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 given DirectoryScanner, 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 outputs
      keepProperties - to keep properties or not
      keepTestNames - to prepend parallel test stage to test name or not
      pipelineTestDetails - A PipelineTestDetails instance containing Pipeline-related additional arguments.
      skipOldReports - to parse or not test files older than filesTimestamp
      Throws:
      IOException
    • TestResult

      public TestResult(TestResultImpl impl)
    • TestResult

      public TestResult(TestResult src)
  • Method Details

    • getPluggableStorage

      @CheckForNull public TestResultImpl getPluggableStorage()
    • getParent

      public TestObject getParent()
      Description copied from class: TestObject
      Reverse pointer of TabulatedResult.getChildren().
      Specified by:
      getParent in class TestObject
      Returns:
      the parent TestObject.
    • setParent

      public void setParent(TestObject parent)
      Description copied from class: TestResult
      Sets the parent test result
      Overrides:
      setParent in class TestResult
      Parameters:
      parent - Parent test result.
    • getTestResult

      public TestResult getTestResult()
      Description copied from class: TestObject
      Returns the top level test result data.
      Overrides:
      getTestResult in class TestObject
    • 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 given DirectoryScanner, while filtering out all files that were created before the given time.
      Parameters:
      filesTimestamp - file timestamp to filter files older.
      results - Directory scanner.
      pipelineTestDetails - A PipelineTestDetails 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 - A PipelineTestDetails instance containing Pipeline-related additional arguments.
      reportFiles - Report files.
      Throws:
      IOException - if an error occurs.
      Since:
      1.22
    • getPreviousResult

      public TestResult getPreviousResult()
      Description copied from class: TestResult
      Gets the counter part of this TestResult in the previous run.
      Overrides:
      getPreviousResult in class TestResult
      Returns:
      null if no such counter part exists.
    • parse

      @Deprecated public void parse(long filesTimestamp, Iterable<File> reportFiles) throws IOException
      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 - A PipelineTestDetails 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
      Collect reports from the given report files
      Parameters:
      reportFiles - Report files.
      pipelineTestDetails - A PipelineTestDetails instance containing Pipeline-related additional arguments.
      Throws:
      IOException - if an error occurs.
    • parse

      @Deprecated public void parse(File reportFile) throws IOException
      Deprecated.
      Throws:
      IOException
    • parse

      public void parse(File reportFile, PipelineTestDetails pipelineTestDetails) throws IOException
      Parses an additional report file.
      Parameters:
      reportFile - Report file to parse.
      pipelineTestDetails - A PipelineTestDetails instance containing Pipeline-related additional arguments.
      Throws:
      IOException - if an error occurs.
      Since:
      1.22
    • getDisplayName

      public String getDisplayName()
    • getRun

      public Run<?,?> getRun()
      Overrides:
      getRun in class TestObject
      Returns:
      the run in which this test was executed.
    • findCorrespondingResult

      public TestResult findCorrespondingResult(String id)
      Description copied from class: TestObject
      Find the test result corresponding to the one identified by id within this test result.
      Specified by:
      findCorrespondingResult in class TestObject
      Parameters:
      id - The path to the original test result
      Returns:
      A corresponding test result, or null if there is no corresponding result.
    • getTitle

      public String getTitle()
      Description copied from class: TestResult
      Gets the human readable title of this result object.
      Overrides:
      getTitle in class TestResult
      Returns:
      the human readable title of this result object.
    • getChildTitle

      public String getChildTitle()
      Overrides:
      getChildTitle in class TabulatedResult
    • getChildType

      public String getChildType()
      Description copied from class: TabulatedResult
      Get a simple name for the type of children the TabulatedResult.getChildren() method returns, for example "case", "class" or "package".
      Overrides:
      getChildType in class TabulatedResult
      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 class TestResult
      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 class TestResult
      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 class TestResult
      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 class TestResult
      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 class TestObject
      Returns:
      the total number of tests.
    • isEmpty

      @Exported(visibility=999) public boolean isEmpty()
      Returns true if this doesn't have any any test results.
      Returns:
      whether this doesn't contain any test results.
      Since:
      1.511
    • getFailedTests

      public List<CaseResult> getFailedTests()
      Description copied from class: MetaTabulatedResult
      All failed tests.
      Specified by:
      getFailedTests in class MetaTabulatedResult
      Returns:
      the children of this test result, if any, or an empty collection
    • getPassedTests

      public List<CaseResult> getPassedTests()
      Gets the "children" of this test result that passed
      Overrides:
      getPassedTests in class TestResult
      Returns:
      the children of this test result, if any, or an empty collection
    • getSkippedTests

      public List<CaseResult> getSkippedTests()
      Gets the "children" of this test result that were skipped
      Overrides:
      getSkippedTests in class TestResult
      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 class TestResult
      Returns:
      the build number when this test started failing.
    • getFailedSinceRun

      public Run<?,?> getFailedSinceRun()
      If this test failed, then return the run when this test started failing.
      Overrides:
      getFailedSinceRun in class TestResult
      Returns:
      the run when this test started failing.
    • getStdout

      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 class TestResult
      Returns:
      the stdout of this test.
      Since:
      1.294
    • getStderr

      public String getStderr()
      The stderr of this test.
      Overrides:
      getStderr in class TestResult
      Returns:
      the stderr of this test.
      Since:
      1.294
      See Also:
    • getProperties

      public Map<String,String> getProperties()
      Overrides:
      getProperties in class TestResult
    • getErrorStackTrace

      public String getErrorStackTrace()
      If there was an error or a failure, this is the stack trace, or otherwise null.
      Overrides:
      getErrorStackTrace in class TestResult
      Returns:
      the stack trace of the error or failure.
    • getErrorDetails

      public String getErrorDetails()
      If there was an error or a failure, this is the text from the message.
      Overrides:
      getErrorDetails in class TestResult
      Returns:
      the message of the error or failure.
    • isPassed

      public boolean isPassed()
      Overrides:
      isPassed in class TestResult
      Returns:
      true if the test was not skipped and did not fail, false otherwise.
    • getChildren

      public Collection<PackageResult> getChildren()
      Description copied from class: TabulatedResult
      Gets the child test result objects.
      Specified by:
      getChildren in class TabulatedResult
      Returns:
      the child test result objects.
      See Also:
    • hasChildren

      public boolean hasChildren()
      Whether this test result has children.
      Specified by:
      hasChildren in class TabulatedResult
    • getSuites

      @Exported(inline=true, visibility=9) public Collection<SuiteResult> getSuites()
    • getName

      public String getName()
      Description copied from class: TestObject
      Gets the name of this object.
      Overrides:
      getName in class TestObject
      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 class TestObject
    • byPackage

      public PackageResult byPackage(String packageName)
    • getSuite

      @CheckForNull public SuiteResult getSuite(String name)
      Returns the first suite with the given name. Prefer using getSuites(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

      @NonNull public Collection<SuiteResult> getSuites(String name)
      Returns all suites with the given name.
      Parameters:
      name - the suite name
      Returns:
      all suites with the given name
    • getResultByNode

      @NonNull public TestResult getResultByNode(@NonNull String nodeId)
    • getResultByNodes

      @NonNull public TestResult getResultByNodes(@NonNull List<String> nodeIds)
    • setParentAction

      public void setParentAction(AbstractTestResultAction action)
      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 class TestResult
      Parameters:
      action - Action that points to the top level test result.
    • getParentAction

      public AbstractTestResultAction getParentAction()
      Description copied from class: TestResult
      Returns the action that points to the top level test result includes this test result.
      Overrides:
      getParentAction in class TestResult
      Returns:
      action The action that points to the top level test result.
    • tally

      public void tally()
      Recount my children.
      Overrides:
      tally in class TestResult
    • freeze

      public void freeze(TestResultAction parent)
      Builds up the transient part of the data structure from results parsed so far.

      After the data is frozen, more files can be parsed and then freeze can be called again.

    • getResultForPipelineBlock

      @NonNull public TestResult getResultForPipelineBlock(@NonNull String blockId)
    • isSkipOldReports

      public boolean isSkipOldReports()
    • setSkipOldReports

      public void setSkipOldReports(boolean skipOldReports)
    • blockToTestResult

      @NonNull public TabulatedResult blockToTestResult(@NonNull PipelineBlockWithTests block, @NonNull TabulatedResult fullResult)
      Get an aggregated TestResult for all test results in a PipelineBlockWithTests and any children it may have.
      Overrides:
      blockToTestResult in class TabulatedResult
    • getCase

      public CaseResult getCase(String suiteName, String transformedFullDisplayName)