|
JUnit-addons version 1.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--junit.framework.Assert | +--junit.framework.TestCase | +--junitx.extensions.ComparabilityTestCase
Extend me in order to test a class's functional compliance with the
Comparable
interface.
Override my createLessInstance
,
createEqualInstance
, and
createGreaterInstance
methods to
provide me with objects to test against. These methods should return
objects that are of the same class.
Comparable
Constructor Summary | |
ComparabilityTestCase(java.lang.String name)
Creates a new test. |
Method Summary | |
protected void |
checkForEquality(java.lang.Comparable c1,
java.lang.Comparable c2)
Override as a no-op if you do not require that createEqualInstance() return distinct but
equivalent objects. |
protected abstract java.lang.Comparable |
createEqualInstance()
Creates and returns an instance of the class under test. |
protected abstract java.lang.Comparable |
createGreaterInstance()
Creates and returns an instance of the class under test. |
protected abstract java.lang.Comparable |
createLessInstance()
Creates and returns an instance of the class under test. |
protected void |
setUp()
Sets up the test fixture. |
void |
testForClassCastException()
Tests whether compareTo throws a ClassCastException when
appropriate. |
void |
testForReverseSigns()
Tests whether sgn(x.compareTo(y)) == -sgn(y.compareTo(x))
for all x and y given to this test. |
void |
testForSameSigns()
Tests whether sgn(x.compareTo(z)) == sgn(y.compareTo(z))
for all z when x.compareTo(y) == 0 . |
void |
testReturnValues()
Tests for sensible return values from the class under test's compareTo method. |
Methods inherited from class junit.framework.TestCase |
countTestCases, createResult, getName, name, run, run, runBare, runTest, setName, tearDown, toString |
Methods inherited from class junit.framework.Assert |
assert, assert, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ComparabilityTestCase(java.lang.String name)
name
- name of the testMethod Detail |
protected abstract java.lang.Comparable createLessInstance() throws java.lang.Exception
createEqualInstance()
java.lang.Exception
protected abstract java.lang.Comparable createEqualInstance() throws java.lang.Exception
java.lang.Exception
protected abstract java.lang.Comparable createGreaterInstance() throws java.lang.Exception
createEqualInstance()
java.lang.Exception
protected void setUp() throws java.lang.Exception
setUp
in class junit.framework.TestCase
java.lang.Exception
protected void checkForEquality(java.lang.Comparable c1, java.lang.Comparable c2)
createEqualInstance()
return distinct but
equivalent objects.
public final void testForReverseSigns()
sgn(x.compareTo(y)) == -sgn(y.compareTo(x))
for all x
and y
given to this test.
public final void testForSameSigns()
sgn(x.compareTo(z)) == sgn(y.compareTo(z))
for all z
when x.compareTo(y) == 0
.
public final void testReturnValues()
compareTo
method. Doing so effectively tests the
transitivity of compareTo
also--
(x.compareTo(y)>0 && y.compareTo(z)>0)
implies
x.compareTo(z)>0
.
public final void testForClassCastException() throws java.lang.Exception
compareTo
throws a ClassCastException when
appropriate.
java.lang.Exception
|
JUnit-addons version 1.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |