Package ucb.test

Class TimedTestFramework


  • public abstract class TimedTestFramework
    extends Object
    An abstract class that provides a rudimentary testing framework. Subtypes of TimedTestFramework should call 'check' for each individual test to check the results, or 'failure' to indicate that a test has "blown up".
    • Field Detail

      • testCount

        protected int testCount
      • wrongCount

        protected int wrongCount
      • badCount

        protected int badCount
      • currentTestName

        protected String currentTestName
      • realStandardOutput

        protected final PrintStream realStandardOutput
      • realStandardError

        protected final PrintStream realStandardError
      • outputLimit

        protected int outputLimit
    • Constructor Detail

      • TimedTestFramework

        protected TimedTestFramework()
    • Method Detail

      • report

        protected void report()
      • setVerbosity

        protected void setVerbosity​(boolean verbose)
      • setTestName

        protected void setTestName​(String name)
      • captureStandardOutput

        protected void captureStandardOutput()
        Start storing up the standard output into a string. You can later retrieve it with getCapturedOutput () and restore the initial standard output with restoreStandardOutput (). Throws away any previously saved output.
      • restoreStandardOutput

        protected void restoreStandardOutput()
        Stop capturing standard output, and revert to initial behavior.
      • getCapturedOutput

        protected String getCapturedOutput()
        Return the captured output from the standard output.
      • getCapturedError

        protected String getCapturedError()
        Return the captured output from the standard error output.
      • check

        protected void check​(boolean test)
        Check that TEST is true, printing PASSED or ERROR messages accordingly and updating test and error counts.
      • check

        protected void check​(Object correct,
                             Object test)
        Check that CORRECT is equal to TEST, using the "same" test below.
      • check

        protected void check​(String msg,
                             Object correct,
                             Object test)
        Check that CORRECT is equal to TEST, using the "same" test below. Prints the message MSG if it is not.
      • check

        protected void check​(String msg,
                             boolean test)
        Check that TEST is true, printing either a PASSED message or or an ERROR message incorporating MSG accordingly and updating test and error counts.
      • failure

        protected void failure​(String msg)
        Report a "failure" (typically a test that blows up instead of producing a result). Use MSG as the explanation.
      • failure

        protected void failure​(Throwable e)
        Report a "failure" from exception E.
      • same

        public static boolean same​(Object x,
                                   Object y)
        True iff X equals Y in the sense that either 1) X and Y are arrays of the same length and their respective elements are == (if primitive) and (recursively) the same otherwise; or 2) X and Y are both null. or 3) X.equals(Y).
      • sameArrays

        public static boolean sameArrays​(Object x,
                                         Object y)
      • getTestCount

        public int getTestCount()
        Cumulative number of calls to check.
      • getPassedCount

        public int getPassedCount()
        Passed tests.
      • getWrongCount

        public int getWrongCount()
        Cumulative number of calls to where the arguments were not the same.
      • getBadCount

        public int getBadCount()
        Cumulative number of "bad" tests: those causing an exception
      • getErrorCount

        public int getErrorCount()
        Cumulative count of tests that fail due to exceptions.