|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
consciouscode.junit.TestCase
public abstract class TestCase
Base class with common assertions used in JUnit test cases.
selectedValue
selectedValue.name
selectedValues[3]
widgets(entryList)
Field Summary | |
---|---|
static String |
AUTO_SUITES
By default, all subclasses will be in the 'common' suite. |
Constructor Summary | |
---|---|
TestCase()
|
|
TestCase(String name)
|
Method Summary | |
---|---|
static void |
assertContained(Object item,
Collection<?> collection)
|
static void |
assertEqualContents(List<?> list,
Collection<?> collection)
Assert that a collection has the same elements as a list, though not in any particular order. |
static void |
assertEqualContents(Object[] expected,
Collection<?> collection)
Asserts that a collection has the same elements as an array, though not in any particular order. |
static void |
assertEqualElements(Object[] array,
List<?> list)
|
static void |
assertEqualElements(Object[] expected,
Object[] found)
|
static void |
assertEqualMembers(Object lhs,
Object rhs)
Asserts that the given objects have equal members. |
static void |
assertEquals(int[] expected,
int[] found)
|
static void |
assertNotContained(Object item,
Collection<?> collection)
|
static void |
assertNotEquals(int left,
int right)
Asserts that two ints are not equal. |
static void |
assertNotEquals(Object left,
Object right)
Asserts that two objects are not equal. |
static void |
assertNotEquals(String message,
int left,
int right)
Asserts that two ints are not equal. |
static void |
assertNotEquals(String message,
Object left,
Object right)
Asserts that two objects are not equal. |
static void |
assertPropertyEquals(boolean expected,
Object bean,
String property)
Asserts that a JavaBean property has an expected boolean value. |
static void |
assertPropertyEquals(int expected,
Object bean,
String property)
Asserts that a JavaBean property has an expected int value. |
static void |
assertPropertyEquals(Object expected,
Object bean,
String property)
Asserts that a JavaBean property has an expected object value. |
static void |
fail(String message,
Throwable cause)
Fails a test with the given message. |
static void |
fail(Throwable cause)
Fails a test with no specific message. |
static Object |
getProperty(Object bean,
String property)
Gets the value of a JavaBean property. |
protected Properties |
loadTestPropertiesFile()
|
protected File |
projectFile(String relativePath)
Retrieves a file relative to the project root directory. |
static void |
setProperty(Object bean,
String property,
boolean value)
Sets the value of a boolean JavaBean property. |
static void |
setProperty(Object bean,
String property,
int value)
Sets the value of an int JavaBean property. |
static void |
setProperty(Object bean,
String property,
Object value)
Sets the value of a JavaBean property. |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString |
Methods inherited from class junit.framework.Assert |
---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, 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 |
Field Detail |
---|
public static final String AUTO_SUITES
AutoSuite
,
Constant Field ValuesConstructor Detail |
---|
public TestCase()
public TestCase(String name)
Method Detail |
---|
public static Object getProperty(Object bean, String property) throws junit.framework.AssertionFailedError
bean
- the JavaBean whose property is being inspected.property
- specifies the desired property. See above for syntax
and examples.
junit.framework.AssertionFailedError
- if any problem occurs while getting the
property value.for finer-grained
control over exception handling.
public static void setProperty(Object bean, String property, Object value) throws junit.framework.AssertionFailedError
bean
- the JavaBean whose property is being changed.property
- specifies the desired property. See above for syntax
and examples.value
- the new value for the property.
junit.framework.AssertionFailedError
- if any problem occurs while getting the
property value.for finer-grained
control over exception handling.
public static void setProperty(Object bean, String property, boolean value) throws junit.framework.AssertionFailedError
bean
- the JavaBean whose property is being changed.property
- specifies the desired property. See above for syntax
and examples.value
- the new value for the property.
junit.framework.AssertionFailedError
- if any problem occurs while getting the
property value.for finer-grained
control over exception handling.
public static void setProperty(Object bean, String property, int value) throws junit.framework.AssertionFailedError
int
JavaBean property.
If any exceptions are
encountered (e.g., one thrown by a setter-method), an
assertion failure is thrown.
bean
- the JavaBean whose property is being changed.property
- specifies the desired property. See above for syntax
and examples.value
- the new value for the property.
junit.framework.AssertionFailedError
- if any problem occurs while getting the
property value.for finer-grained
control over exception handling.
public static void fail(Throwable cause) throws junit.framework.AssertionFailedError
junit.framework.AssertionFailedError
- in all cases.public static void fail(String message, Throwable cause) throws junit.framework.AssertionFailedError
junit.framework.AssertionFailedError
- in all cases.public static void assertNotEquals(int left, int right)
public static void assertNotEquals(String message, int left, int right)
public static void assertNotEquals(Object left, Object right)
public static void assertNotEquals(String message, Object left, Object right)
public static void assertEqualMembers(Object lhs, Object rhs)
EqualsBuilder.reflectionEquals(Object, Object)
,
which uses reflection to access the members of each object.
Transient members are not tested.
public static void assertPropertyEquals(boolean expected, Object bean, String property)
junit.framework.AssertionFailedError
- if the property doesn't have the expected
value.public static void assertPropertyEquals(int expected, Object bean, String property)
int
value.
junit.framework.AssertionFailedError
- if the property doesn't have the expected
value.public static void assertPropertyEquals(Object expected, Object bean, String property)
junit.framework.AssertionFailedError
- if the property doesn't have the expected
value.public static void assertEquals(int[] expected, int[] found)
public static void assertEqualElements(Object[] expected, Object[] found)
public static void assertEqualContents(Object[] expected, Collection<?> collection)
NOTE that this assumes that there are no two equals
elements in the array.
public static void assertEqualContents(List<?> list, Collection<?> collection)
NOTE that this assumes that there are no two equals
elements
in the list.
public static void assertEqualElements(Object[] array, List<?> list)
public static void assertContained(Object item, Collection<?> collection)
public static void assertNotContained(Object item, Collection<?> collection)
protected Properties loadTestPropertiesFile() throws IOException
IOException
protected File projectFile(String relativePath)
File
instance; not null
.
IllegalArgumentException
- if the file doesn't exist.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |