Class TestResult

    • Field Detail

      • FILE_TIME_PRECISION_MARGIN

        public static final long FILE_TIME_PRECISION_MARGIN
    • Constructor Detail

      • TestResult

        public TestResult()
        Creates an empty result.
      • TestResult

        @Deprecated
        public TestResult​(boolean keepLongStdio)
        Deprecated.
        Since:
        1.522
      • 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,
                          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

        public TestResult​(long filesTimestamp,
                          org.apache.tools.ant.DirectoryScanner results,
                          StdioRetention stdioRetention,
                          boolean keepProperties,
                          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
        pipelineTestDetails - A PipelineTestDetails instance containing Pipeline-related additional arguments.
        skipOldReports - to parse or not test files older than filesTimestamp
        Throws:
        IOException
    • Method Detail

      • getPluggableStorage

        @CheckForNull
        public TestResultImpl getPluggableStorage()
      • 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.
      • 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

        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
      • 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

        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.
      • 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
      • 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
      • 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.
      • hasChildren

        public boolean hasChildren()
        Whether this test result has children.
        Specified by:
        hasChildren in class TabulatedResult
      • 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
      • 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)
      • 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)