|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object becker.util.Test
public class Test
Methods to assist in testing code. Example usage:
public static void main(String[] args) { Patron p = new Patron(1001); Test.ckEquals("patron ID#", 1001, p.getID()); }Each method prints a message on the console indicating whether the test passed or failed and what the expected and actual values were compared.
Field Summary | |
---|---|
static double |
EPSILON
The default value for testing doubles for equality. |
Constructor Summary | |
---|---|
Test()
An instance may be created, but is not required as all the methods are declared static. |
Method Summary | |
---|---|
static void |
ckEquals(String idString,
boolean expected,
boolean actual)
Check two booleans for equality. |
static void |
ckEquals(String idString,
char expected,
char actual)
Check two characters for equality. |
static void |
ckEquals(String idString,
double expected,
double actual)
Check two doubles for equality, using EPSILON as a tolerance. |
static void |
ckEquals(String idString,
double expected,
double actual,
double epsilon)
Check two doubles for equality within a specified tolerance. |
static void |
ckEquals(String idString,
int expected,
int actual)
Check two integers for equality. |
static void |
ckEquals(String idString,
Object expected,
Object actual)
Check two Objects for equality using the .equals method. |
static void |
ckEquals(String idString,
String expected,
String actual)
Check two strings for equality. |
static void |
ckEqualsIgnoreCase(String idString,
String expected,
String actual)
Check two strings for equality, ignoring any differences in case. |
static void |
ckIdentical(String idString,
Object expected,
Object actual)
Check that two Objects are identical using ==. |
static void |
ckIsBetween(String idString,
char minExpected,
char actual,
char maxExpected)
Check that a char is between a given minimum and maximum. |
static void |
ckIsBetween(String idString,
double minExpected,
double actual,
double maxExpected)
Check that a double is between a given minimum and maximum. |
static void |
ckIsBetween(String idString,
int minExpected,
int actual,
int maxExpected)
Check an integer is between a given minimum and maximum. |
static void |
ckIsBetween(String idString,
String minExpected,
String actual,
String maxExpected)
Check that a String is between a given minimum and maximum. |
static void |
ckIsNotNull(String idString,
Object actual)
Check that a value is not null. |
static void |
ckIsNull(String idString,
Object actual)
Check that a value is null. |
static void |
fail(String idString)
Indicate that a test failed. |
static int |
getNumErrors()
Get the number of errors found in this program. |
static void |
pass(String idString)
Indicate that a test passed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final double EPSILON
Constructor Detail |
---|
public Test()
Method Detail |
---|
public static void ckEquals(String idString, int expected, int actual)
idString
- a string identifying this testexpected
- the value expected for this testactual
- the value actually obtained for this testpublic static void ckEquals(String idString, double expected, double actual, double epsilon)
idString
- a string identifying this testexpected
- the value expected for this testactual
- the value actually obtained for this testepsilon
- the value by which the two doubles are allowed to deviatepublic static void ckEquals(String idString, double expected, double actual)
idString
- a string identifying this testexpected
- the value expected for this testactual
- the value actually obtained for this testpublic static void ckEquals(String idString, boolean expected, boolean actual)
idString
- a string identifying this testexpected
- the value expected for this testactual
- the value actually obtained for this testpublic static void ckEquals(String idString, char expected, char actual)
idString
- a string identifying this testexpected
- the value expected for this testactual
- the value actually obtained for this testpublic static void ckEquals(String idString, String expected, String actual)
idString
- a string identifying this testexpected
- the value expected for this testactual
- the value actually obtained for this testpublic static void ckEqualsIgnoreCase(String idString, String expected, String actual)
idString
- a string identifying this testexpected
- the value expected for this testactual
- the value actually obtained for this testpublic static void ckEquals(String idString, Object expected, Object actual)
idString
- a string identifying this testexpected
- the value expected for this test (not null)actual
- the value actually obtained for this test (not null)public static void ckIdentical(String idString, Object expected, Object actual)
idString
- a string identifying this testexpected
- the value expected for this test (not null)actual
- the value actually obtained for this test (not null)public static void ckIsBetween(String idString, int minExpected, int actual, int maxExpected)
idString
- a string identifying this testminExpected
- the smallest expected valueactual
- the actual value obtained for the testmaxExpected
- the largest expected valuepublic static void ckIsBetween(String idString, double minExpected, double actual, double maxExpected)
idString
- a string identifying this testminExpected
- the smallest expected valueactual
- the actual value obtained for the testmaxExpected
- the largest expected valuepublic static void ckIsBetween(String idString, char minExpected, char actual, char maxExpected)
idString
- a string identifying this testminExpected
- the smallest expected valueactual
- the actual value obtained for the testmaxExpected
- the largest expected valuepublic static void ckIsBetween(String idString, String minExpected, String actual, String maxExpected)
idString
- a string identifying this testminExpected
- the smallest expected valueactual
- the actual value obtained for the testmaxExpected
- the largest expected valuepublic static void ckIsNull(String idString, Object actual)
idString
- a string identifying this testactual
- the value actually obtained for this testpublic static void ckIsNotNull(String idString, Object actual)
idString
- a string identifying this testactual
- the value actually obtained for this testpublic static void fail(String idString)
idString
- a string identifying this testpublic static void pass(String idString)
idString
- a string identifying this testpublic static int getNumErrors()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |