|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmomeunit.framework.Assert
momeunit.framework.TestCase
public abstract class TestCase
An abstract class that every test case should extend. The TestCase has a
name
property that identifies it. The default value of this
property is is name of TestCase
subclass without 'packages' prefix
(e.g. for class "com.foo.bar.AbcTest" the name of test case will be
"AbcTest"). Name of test case can be set of course using setter
method setName(String)
or constructor TestCase(String)
.
TestCase has methods setUp()
and tearDown()
for
manipulating fixture (instance variables that can be shared by different
tests). Developers should override them for setting instance variables and
cleaning up after test execution respectively. The code that performs tests
and asserts results should be putted in test()
method. To run test
case and obtain results call run()
or run(TestResult)
methods. There is a convenience method for creating an empty TestResult
instance createResult()
.
Test
,
TestSuite
Constructor Summary | |
---|---|
TestCase()
No-arg constructor. |
|
TestCase(String name)
Instantiates TestCase and sets name to the name or classname
of TestCase implementation without packages part and ".class" suffix of
course if name is null . |
Method Summary | |
---|---|
int |
countTestCases()
Returns 1 as the number of test cases that will be run by this test. |
protected TestResult |
createResult()
Creates a default TestResult object |
String |
getName()
Returns the name of this test case. |
TestResult |
run()
A convenience method to run this test, collecting the results with a default TestResult object. |
void |
run(TestResult result)
Runs a test and collects its result in a TestResult instance. |
void |
runBare()
Runs the bare test sequence. |
void |
setName(String name)
Sets name to the name or classname of TestCase
implementation without packages part and ".class" suffix of course if
name is null . |
protected void |
setUp()
Sets up the fixture. |
protected void |
tearDown()
Tears down the fixture. |
abstract void |
test()
Override to run the test and assert its state. |
String |
toString()
Returns a string representation of the test case |
Methods inherited from class momeunit.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, format |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TestCase()
public TestCase(String name)
name
or classname
of TestCase implementation without packages part and ".class" suffix of
course if name
is null
.
name
- name of test case or null to set name to classname.Method Detail |
---|
public void setName(String name)
name
or classname of TestCase
implementation without packages part and ".class" suffix of course if
name
is null
.
name
- name of test case or null to set name to classname.public String getName()
protected TestResult createResult()
public int countTestCases()
countTestCases
in interface Test
Test.countTestCases()
public TestResult run()
public void run(TestResult result)
Test
run
in interface Test
public void runBare() throws Throwable
Throwable
- if any exception is thrownprotected void setUp() throws Exception
Exception
- if any exception is thrown.public abstract void test() throws Throwable
Throwable
- if any exception is thrownprotected void tearDown() throws Exception
Exception
- if any exception is thrownpublic String toString()
toString
in class Object
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |