|
|||||||||||
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 | +--jbeantester.junit.BaseTestCase
This class provides a JUnit compliant test case. The documentation here as well as the code it represents constitute an excellent starting point for those wishing to use this tool effectively (either with or without JUnit).
Please also look at JBeanTest.
Field Summary | |
protected Logger |
cat
A Logger to use in this object and all derivatives. |
Constructor Summary | |
BaseTestCase(String name)
Constructor required by TestCase . |
Method Summary | |
protected JBeanTestResults |
testJBeanConstructor(Class clazz,
String[] params)
Test that the specified constructors function properly. |
protected JBeanTestResults |
testJBeanProperties(Class clazz)
This method is used to test the properties of a default consttucted instance of Class es conforming to the JavaBean
Specification. |
protected JBeanTestResults |
testJBeanProperties(Object obj)
This method is used to test the properties of Objects
conforming to the JavaBean Specification. |
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 |
protected final Logger cat
Constructor Detail |
public BaseTestCase(String name)
TestCase
.
name
- the name for this test case.Method Detail |
protected JBeanTestResults testJBeanProperties(Object obj)
This method is used to test the properties of Objects
conforming to the JavaBean Specification.
An attempt is made to match up mutators (setters) accepting one parameter
with appropriate accessors (getters). For those pairs found, an attempt
is made at constructing input parameters. Each mutator is called with
the appropriate data followed by each accessor to check that the return
value matches.
Input data is constructed with sequentially different values. For non-primitive objects or their wrappers (those items found in java.lang) an attempt is made to construct an instance using the default constructor (no parameters). If this fails, the property is skipped.
Mutators must begin with 'set' while accessors must begin with 'get'
unless the parameter is a boolean
(primitive) in which case
it may also begin with 'is'.
If any Exception
or Error
condition is
encountered while examining the methods, the condition is logged and that
property is ignored.
Note that no JUnit Assertions are made within this method. All results
are returned for processing within the testCase
.
obj
- the object to be tested.
protected JBeanTestResults testJBeanProperties(Class clazz)
This method is used to test the properties of a default consttucted
instance of Class
es conforming to the JavaBean
Specification.
This method constructs an instance of the specified Class
and passes it to the overloaded version of this method accepting an
Object
. Please see the documentation for that method.
If any Exception
or Error
condition is
encountered while examining the methods, the condition is logged and that
property is ignored.
Note that no JUnit Assertions are made within this method. All results
are returned for processing within the testCase
.
Note that this object is not thread safe.
clazz
- the class to be instantiated and tested; error on
null
.
protected JBeanTestResults testJBeanConstructor(Class clazz, String[] params)
Test that the specified constructors function properly.
Test that the constructor exists and that the getters for the specified
properties return the expected values. If the the specified constructor
does not exist, JBeanTestResults.NO_SUCH_CONSTRUCTOR
will be
returned.
clazz
- the class to be tested.params
- the names of the properties which comprise the constructor
to be tested.
JBeanTestResults.NO_SUCH_CONSTRUCTOR
if no such
constructor exists.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |