com.javaranch.common
Class TestLog

java.lang.Object
  |
  +--com.javaranch.common.ErrorLog
        |
        +--com.javaranch.common.TestLog
All Implemented Interfaces:
java.io.Serializable

public class TestLog
extends ErrorLog

Used when unit testing code.

This class is to be used only in conjunction with the UnitTest framework.

See UnitTest.java for details.

- - - - - - - - - - - - - - - - -

Copyright (c) 1999-2004 Paul Wheaton

You are welcome to do whatever you want to with this source file provided that you maintain this comment fragment (between the dashed lines). Modify it, change the package name, change the class name ... personal or business use ... sell it, share it ... add a copyright for the portions you add ...

My goal in giving this away and maintaining the copyright is to hopefully direct developers back to JavaRanch.

The original source can be found at JavaRanch

- - - - - - - - - - - - - - - - -

Author:
Paul Wheaton
See Also:
Serialized Form

Constructor Summary
TestLog()
           
 
Method Summary
 void fail()
          The message "test fail" plus the source file name and line number are added to the log.
 void fail(java.lang.String message)
          The message "test fail:" plus the message, source file name and line number are added to the log.
 void test(boolean b)
          If false is passed in, the message "test fail" plus the source file name and line number are added to the log.
 void test(boolean b, java.lang.String message)
          If false is passed in, the text "test fail: " plus the message, source file name and line number are added to the log.
 void test(char testResult, char expected)
          If the two values do not match, the discrepency, the file name and the line number will be added to the log.
 void test(char testResult, char expected, java.lang.String message)
          If the two values do not match, the discrepency, the message, the file name and the line number will be added to the log.
 void test(int testResult, int expected)
          If the two values do not match, the discrepency, the file name and the line number will be added to the log.
 void test(int testResult, int expected, java.lang.String message)
          If the two values do not match, the discrepency, the message, the file name and the line number will be added to the log.
 void test(long testResult, long expected)
          If the two values do not match, the discrepency, the file name and the line number will be added to the log.
 void test(long testResult, long expected, java.lang.String message)
          If the two values do not match, the discrepency, the message, the file name and the line number will be added to the log.
 void test(java.lang.Object testResult, java.lang.Object expected)
          If the two values do not match, the discrepency, the file name and the line number will be added to the log.
 void test(java.lang.Object testResult, java.lang.Object expected, java.lang.String message)
          If the two values do not match, the discrepency, the message, the file name and the line number will be added to the log.
 void testRange(double testResult, double low, double high)
          If the two values do not match, the discrepency, the file name and the line number will be added to the log.
 void testRange(double testResult, double low, double high, java.lang.String message)
          If the two values do not match, the discrepency, the message, the file name and the line number will be added to the log.
 
Methods inherited from class com.javaranch.common.ErrorLog
add, addAndDisplay, appendLogFile, getList, isConsoleLogOn, isFileLogOn, isInternalLogOn, numErrors, setConsole, setInternalLog, setLogFile, setLogFileOff
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestLog

public TestLog()
Method Detail

fail

public void fail()
The message "test fail" plus the source file name and line number are added to the log.


fail

public void fail(java.lang.String message)
The message "test fail:" plus the message, source file name and line number are added to the log.


test

public void test(boolean b)
If false is passed in, the message "test fail" plus the source file name and line number are added to the log.


test

public void test(boolean b,
                 java.lang.String message)
If false is passed in, the text "test fail: " plus the message, source file name and line number are added to the log.


test

public void test(int testResult,
                 int expected)
If the two values do not match, the discrepency, the file name and the line number will be added to the log.

The message will look similar to this: test result "5" does not match expected value "2".

This method will be used for testing byte and short values too.


test

public void test(int testResult,
                 int expected,
                 java.lang.String message)
If the two values do not match, the discrepency, the message, the file name and the line number will be added to the log.

The message will look similar to this: test result "5" does not match expected value "2". Too many pancakes.

This method will be used for testing byte and short values too.


test

public void test(char testResult,
                 char expected)
If the two values do not match, the discrepency, the file name and the line number will be added to the log.

The message will look similar to this: test result "5" does not match expected value "2".


test

public void test(char testResult,
                 char expected,
                 java.lang.String message)
If the two values do not match, the discrepency, the message, the file name and the line number will be added to the log.

The message will look similar to this: test result "5" does not match expected value "2". Too many pancakes.


test

public void test(long testResult,
                 long expected)
If the two values do not match, the discrepency, the file name and the line number will be added to the log.

The message will look similar to this: test result "5" does not match expected value "2".


test

public void test(long testResult,
                 long expected,
                 java.lang.String message)
If the two values do not match, the discrepency, the message, the file name and the line number will be added to the log.

The message will look similar to this: test result "5" does not match expected value "2". Too many pancakes.


testRange

public void testRange(double testResult,
                      double low,
                      double high)
If the two values do not match, the discrepency, the file name and the line number will be added to the log.

The message will look similar to this: test result "5" does not match expected value "2".

This method will be used for testing float values too.

Because of the imprecision of floating point, floats and doubles must be tested with a range.


testRange

public void testRange(double testResult,
                      double low,
                      double high,
                      java.lang.String message)
If the two values do not match, the discrepency, the message, the file name and the line number will be added to the log.

The message will look similar to this: test result "5" does not match expected value "2". Too many pancakes.

This method will be used for testing float values too.

Because of the imprecision of floating point, floats and doubles must be tested with a range.


test

public void test(java.lang.Object testResult,
                 java.lang.Object expected)
If the two values do not match, the discrepency, the file name and the line number will be added to the log.

The message will look similar to this: test result "5" does not match expected value "2".

Note that the objects must properly implement the equals() method and the toString() method.


test

public void test(java.lang.Object testResult,
                 java.lang.Object expected,
                 java.lang.String message)
If the two values do not match, the discrepency, the message, the file name and the line number will be added to the log.

The message will look similar to this: test result "5" does not match expected value "2". Too many pancakes.

Note that the objects must properly implement the equals() method and the toString() method.



Copyright ©2004 Paul Wheaton All Rights Reserved