Class TestRunResult

  • All Implemented Interfaces:
    ITestRunListener

    public class TestRunResult
    extends java.lang.Object
    implements ITestRunListener
    Holds results from a single test run.

    Maintains an accurate count of tests, and tracks incomplete tests.

    Not thread safe! The test* callbacks must be called in order

    • Constructor Detail

      • TestRunResult

        public TestRunResult()
        Create an emptyTestRunResult.
    • Method Detail

      • setAggregateMetrics

        public void setAggregateMetrics​(boolean metricAggregation)
      • getName

        public java.lang.String getName()
        Returns:
        the test run name
      • getTestResults

        public java.util.Map<TestIdentifier,​TestResult> getTestResults()
        Gets a map of the test results.
        Returns:
      • getRunMetrics

        public java.util.Map<java.lang.String,​java.lang.String> getRunMetrics()
        Returns:
        a Map of the test test run metrics.
      • getCompletedTests

        public java.util.Set<TestIdentifier> getCompletedTests()
        Gets the set of completed tests.
      • isRunFailure

        public boolean isRunFailure()
        Returns:
        true if test run failed.
      • isRunComplete

        public boolean isRunComplete()
        Returns:
        true if test run finished.
      • setRunComplete

        public void setRunComplete​(boolean runComplete)
      • getNumTestsInState

        public int getNumTestsInState​(TestResult.TestStatus status)
        Gets the number of tests in given state for this run.
      • getNumTests

        public int getNumTests()
        Gets the number of tests in this run.
      • getNumCompleteTests

        public int getNumCompleteTests()
        Gets the number of complete tests in this run ie with status != incomplete.
      • hasFailedTests

        public boolean hasFailedTests()
        Returns:
        true if test run had any failed or error tests.
      • getNumAllFailedTests

        public int getNumAllFailedTests()
        Return total number of tests in a failure state (failed, assumption failure)
      • getElapsedTime

        public long getElapsedTime()
        Returns:
      • getRunFailureMessage

        public java.lang.String getRunFailureMessage()
        Return the run failure error message, null if run did not fail.
      • testRunStarted

        public void testRunStarted​(java.lang.String runName,
                                   int testCount)
        Description copied from interface: ITestRunListener
        Reports the start of a test run.
        Specified by:
        testRunStarted in interface ITestRunListener
        Parameters:
        runName - the test run name
        testCount - total number of tests in test run
      • testFailed

        public void testFailed​(TestIdentifier test,
                               java.lang.String trace)
        Description copied from interface: ITestRunListener
        Reports the failure of a individual test case.

        Will be called between testStarted and testEnded.

        Specified by:
        testFailed in interface ITestRunListener
        Parameters:
        test - identifies the test
        trace - stack trace of failure
      • testAssumptionFailure

        public void testAssumptionFailure​(TestIdentifier test,
                                          java.lang.String trace)
        Description copied from interface: ITestRunListener
        Called when an atomic test flags that it assumes a condition that is false
        Specified by:
        testAssumptionFailure in interface ITestRunListener
        Parameters:
        test - identifies the test
        trace - stack trace of failure
      • testIgnored

        public void testIgnored​(TestIdentifier test)
        Description copied from interface: ITestRunListener
        Called when a test will not be run, generally because a test method is annotated with org.junit.Ignore.
        Specified by:
        testIgnored in interface ITestRunListener
        Parameters:
        test - identifies the test
      • testRunFailed

        public void testRunFailed​(java.lang.String errorMessage)
        Description copied from interface: ITestRunListener
        Reports test run failed to complete due to a fatal error.
        Specified by:
        testRunFailed in interface ITestRunListener
        Parameters:
        errorMessage - String describing reason for run failure.
      • testRunStopped

        public void testRunStopped​(long elapsedTime)
        Description copied from interface: ITestRunListener
        Reports test run stopped before completion due to a user request.

        TODO: currently unused, consider removing

        Specified by:
        testRunStopped in interface ITestRunListener
        Parameters:
        elapsedTime - device reported elapsed time, in milliseconds
      • testRunEnded

        public void testRunEnded​(long elapsedTime,
                                 java.util.Map<java.lang.String,​java.lang.String> runMetrics)
        Description copied from interface: ITestRunListener
        Reports end of test run.
        Specified by:
        testRunEnded in interface ITestRunListener
        Parameters:
        elapsedTime - device reported elapsed time, in milliseconds
        runMetrics - key-value pairs reported at the end of a test run
      • getTextSummary

        public java.lang.String getTextSummary()
        Return a user friendly string describing results.
        Returns: