background image
<< Java Test Harness | Stub Sequence Verification >>
<< Java Test Harness | Stub Sequence Verification >>

Test Class Primitives

Automated Testing
You must be especially aware of these constraints when importing existing test cases
into Rational Test RealTime
Naming Conventions
Test class names should be prefixed with
Test
, as in
Test<ClassUnderTest>
Where
<ClassUnderTest>
is the name of the class under test. This naming convention
enables the test class to use test class primitives.
Test method names must be prefixed with
test
, as in:
test<TestName>
Where
<TestName>
is the name of the test.
Test Class Primitives
The test class defines the primitives that create and test the objects under test. The
test class primitives are:
·
Creation of the objects under test: This primitive must create and initialize all
the objects under test.
void setUp() throws Exception
setUp:
·
End of test: Use this primitive to insert any code that is required to end the test,
such as to set any setUp created objects to null.
void tearDown() throws Exception
tearDown:
·
Test Primitives: The test class must also define as many test
<TestName>
methods as there are tests.
You can inject such a
TestCase
into a
TestSuite
. This way, The
TestSuite
automatically
creates as many
TestCase
s as requires and executes a sequential run of all the tests.
Running a Test
To run a series of tests, you must incorporate a
ma n
inside a
TestCase
or
TestSuite
class, build the
main
, the
TestSuite
and
TestClass
, and execute the run.
i
In J2ME, these objects can be built in a midlet, which contains only
TestSuite
and
TestCase
, and launches the run on the
start app
primitive. If the test case was
generated by Test RealTime, you must comment the main method that was
automatically generated.
179