Class TestResult

All Implemented Interfaces:
ModelObject, SearchableModelObject, SearchItem, Serializable
Direct Known Subclasses:
CaseResult, SimpleCaseResult, TabulatedResult

public abstract class TestResult extends TestObject
A class that represents a general concept of a test result, without any language or implementation specifics. Subclasses must add @Exported annotation to the fields they want to export.
Since:
1.343
See Also:
  • Constructor Details

    • TestResult

      public TestResult()
  • Method Details

    • setParentAction

      public void setParentAction(AbstractTestResultAction action)
      If the concept of a parent action is important to a subclass, then it should provide a non-noop implementation of this method.
      Parameters:
      action - Action that points to the top level test result.
    • getParentAction

      public AbstractTestResultAction getParentAction()
      Returns the action that points to the top level test result includes this test result.
      Returns:
      action The action that points to the top level test result.
    • tally

      public void tally()
      Request that the result update its counts of its children. Does not require a parent action or owner or siblings. Subclasses should implement this, unless they are *always* in a tallied state.
    • setParent

      public void setParent(TestObject parent)
      Sets the parent test result
      Parameters:
      parent - Parent test result.
    • getTitle

      public String getTitle()
      Gets the human readable title of this result object.
      Returns:
      the human readable title of this result object.
    • getBuildResult

      public Result getBuildResult()
      Mark a build as unstable if there are failures. Otherwise, leave the build result unchanged.
      Returns:
      Result.UNSTABLE if there are test failures, null otherwise.
    • getDuration

      public float getDuration()
      Time it took to run this test. In seconds.
      Specified by:
      getDuration in class TestObject
      Returns:
      the time in seconds the test ran.
    • getPassCount

      public int getPassCount()
      Gets the total number of passed tests.
      Specified by:
      getPassCount in class TestObject
      Returns:
      the total number of passed tests.
    • getFailCount

      public int getFailCount()
      Gets the total number of failed tests.
      Specified by:
      getFailCount in class TestObject
      Returns:
      the total number of failed tests.
    • getSkipCount

      public int getSkipCount()
      Gets the total number of skipped tests.
      Specified by:
      getSkipCount in class TestObject
      Returns:
      the total number of skipped tests.
    • getPreviousResult

      public TestResult getPreviousResult()
      Gets the counter part of this TestResult in the previous run.
      Specified by:
      getPreviousResult in class TestObject
      Returns:
      null if no such counter part exists.
    • getResultInRun

      public TestResult getResultInRun(Run<?,?> build)
      Gets the counter part of this TestResult in the specified run.
      Overrides:
      getResultInRun in class TestObject
      Parameters:
      build - The run for which the run is requested.
      Returns:
      null if no such counter part exists.
    • getFailedTests

      public Collection<? extends TestResult> getFailedTests()
      Gets the "children" of this test result that failed
      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
      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
      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.
      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.
      Returns:
      the run when this test started failing.
    • getStdout

      public String getStdout()
      The stdout of this test.
      Returns:
      the stdout of this test.
    • getStderr

      public String getStderr()
      The stderr of this test.
      Returns:
      the stderr of this test.
    • getErrorStackTrace

      public String getErrorStackTrace()
      If there was an error or a failure, this is the stack trace, or otherwise null.
      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.
      Returns:
      the message of the error or failure.
    • getProperties

      public Map<String,String> getProperties()
    • getFlakyFailures

      public List<Failure> getFlakyFailures()
    • getRerunFailures

      public List<Failure> getRerunFailures()
    • isPassed

      public boolean isPassed()
      Returns:
      true if the test was not skipped and did not fail, false otherwise.
    • toPrettyString

      public String toPrettyString()
    • annotate

      public String annotate(String text)
      All JUnit test output (error message, stack trace, std out, std err) shown on the single test case result page is passed through this method when the page is rendered, which processes / sanitizes the text to make it suitable for HTML rendering. Attempts to auto-detect URLs in the test output and convert them to clickable links for convenience. All other HTML will be escaped.

      Additionally, passes the test output through all the TestActions associated with this result, giving them a chance to apply their own custom rendering / transformations.

      Note: The test output shown when expanding cases on the full "testReport" page is *not* passed through this method, and instead relies on the Jelly "escape-by-default" flag to escape test output for HTML rendering, which is why links are not clickable in that context.

      Parameters:
      text - Text to use to annotate the actions.
      Returns:
      the provided text with URLs converted to sanitized <a> tags and all other HTML escaped.