Class TestCase

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<TestCase> children
      The list of children if this is a suite according to isTest() or null if this is a (singular) test.
      private Description desc
      The description of this testcase.
      private Failure failure
      The failure if any; otherwise null.
      private int idxTest
      The index of this testcase if this is a (singular) test; otherwise -1.
      private Quality qual
      The phase of this testcase.
      private long time
      If this testcase is a single testcase which has been finished, this is the span of time required to run this test.
      (package private) static long TIME_SCHEDULED  
      private static long TIME_SUITE  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      (package private) TestCase​(Description desc)
      Creates a new testcase based on the description desc with indices 0...n-1, where n is the testcout of desc.
      private TestCase​(Description desc, int idxTest)
      Creates a new testcase based on the description desc with indices idxTest...idxTest+n-1, where n is the testcout of desc.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) boolean fullSuccess()
      Returns whether this test including all sub-tests succeeded.
      (package private) java.util.List<TestCase> getChildren()
      Returns the list of children given by children.
      (package private) Description getDesc()
      Returns the description of this testcase given by desc.
      (package private) int getIdx()
      Returns the index of this testcase as described in idxTest.
      (package private) Quality getQuality()
      Returns the phase of this testcase as described in qual.
      (package private) java.lang.Throwable getThrown()
      Returns null if no failure occurred.
      (package private) long getTime()
      If this testcase is a single testcase which has been finished, this is the span of time required to run this test.
      (package private) boolean hasFailed()
      Returns whether getThrown() returns non-null.
      (package private) boolean isTest()
      Returns whether this testcase is a (singular) test.
      (package private) void setAssumptionFailure​(Failure failure)
      Triggers a transition of the current phase if the assumption failure failure occurs.
      (package private) void setFailure​(Failure failure)
      Triggers a transition of the current phase if the non-assumption failure failure occurs.
      (package private) void setFinished()
      Triggers a transition of the current phase given by finishing the run of a singular testcase if possible as specified by Quality.setFinished().
      (package private) void setQualStartedIgnored​(Quality qual)
      Triggers a transition of the current phase to qual if possible; otherwise throws an exception.
      (package private) void setScheduledRec()
      Recursively triggers a transition of the current phase to Quality.Scheduled: If this is a test, just set qual to Quality.Scheduled if possible updating failure and time.
      (package private) int testCount()
      Returns the number of singular test in this testcase.
      java.lang.String toString()
      Returns the string representation of desc for suites and a representation including qual for singular tests.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • desc

        private final Description desc
        The description of this testcase. This may be singular or not.
      • children

        private final java.util.List<TestCase> children
        The list of children if this is a suite according to isTest() or null if this is a (singular) test.
      • idxTest

        private final int idxTest
        The index of this testcase if this is a (singular) test; otherwise -1. Each testcase is part of a tree hierarchy in which the singular tests have indices 0...n-1 if there are n singular test.
      • qual

        private Quality qual
        The phase of this testcase. The phase is null iff this testcase is a suite. Otherwise, If this test is singular and newly created, the quality is Quality.Scheduled. State transitions are reigned by Quality.
      • failure

        private Failure failure
        The failure if any; otherwise null. This is null iff
        • this is a test suite according to isTest() and thus qual is null.
        • this is a singular test (thus the phase qual is non-null) and a failure is associated with the phase according to Quality.hasFailure().
      • time

        private long time
        If this testcase is a single testcase which has been finished, this is the span of time required to run this test. For single ignored tests, this is 0 and in the other cases, the value is negative. If this testcase is a suite, the result is TIME_SUITE; otherwise if scheduled it is TIME_SCHEDULED, both negative.
        See Also:
        Quality.setTime(long)
    • Constructor Detail

      • TestCase

        TestCase​(Description desc)
        Creates a new testcase based on the description desc with indices 0...n-1, where n is the testcout of desc. This testcase is the root of a hierarchy of tests which consists of a single test if desc is singular.

        All singular tests have quality Quality.Scheduled.

        Parameters:
        desc - a description of this testcase. This may be singular or a test suite.
      • TestCase

        private TestCase​(Description desc,
                         int idxTest)
        Creates a new testcase based on the description desc with indices idxTest...idxTest+n-1, where n is the testcout of desc. This testcase is the root of a hierarchy of tests which consists of a single test if desc is singular.

        All singular tests have quality Quality.Scheduled.

        Parameters:
        desc - a description of this testcase. This may be singular or a test suite.
        idxTest - the minimal index of the (singular) tests to be created. To create the root of
    • Method Detail

      • getDesc

        Description getDesc()
        Returns the description of this testcase given by desc. This may be singular or not.
        Returns:
        desc.
      • isTest

        boolean isTest()
        Returns whether this testcase is a (singular) test. Otherwise it is a testsuite. This is a frequently used convenience method.
        Returns:
        this testcase is a (singular) test.
        See Also:
        Description.isTest()
      • testCount

        int testCount()
        Returns the number of singular test in this testcase. This is 1 iff this is a singular test according to isTest(). This is a convenience method used once.
        Returns:
        the number of singular test in this testcase.
        See Also:
        Description.testCount()
      • getChildren

        java.util.List<TestCase> getChildren()
        Returns the list of children given by children.
        Returns:
        • null if this is a test suite according to isTest().
        • the list of children of this suite otherwise.
      • getIdx

        int getIdx()
        Returns the index of this testcase as described in idxTest.
        Returns:
        idxTest
      • getQuality

        Quality getQuality()
        Returns the phase of this testcase as described in qual.
        Returns:
        qual
      • getTime

        long getTime()
        If this testcase is a single testcase which has been finished, this is the span of time required to run this test. For single ignored tests, this is 0 and in the other cases, the value is negative. If this testcase is a suite, the result is -3.
        Returns:
        time
        See Also:
        Quality.setTime(long)
      • fullSuccess

        boolean fullSuccess()
        Returns whether this test including all sub-tests succeeded.
        Returns:
        whether this test including all sub-tests succeeded.
      • setQualStartedIgnored

        void setQualStartedIgnored​(Quality qual)
        Triggers a transition of the current phase to qual if possible; otherwise throws an exception.
        Parameters:
        qual - either Quality.Started or Quality.Ignored.
        Throws:
        java.lang.IllegalStateException -
        java.lang.NullPointerException - if this is a test suite and thus qual is null.
      • toString

        public java.lang.String toString()
        Returns the string representation of desc for suites and a representation including qual for singular tests.
        Overrides:
        toString in class java.lang.Object