Java Reference
In-Depth Information
When you use JUnit, you design a companion test class for each class that you
develop. Two versions of JUnit are currently in common use, 3 and 4. We describe
both versions. In JUnit 3, your test class has two essential properties:
ȗ
The test class must extend the class TestCase from the
junit.framework package.
ȗ
For each test case, you must define a method whose name starts with test ,
such as testSimpleCase .
Figure 6
Unit Testing with JUnit
372
373
In each test case, you make some computations and then compute some condition that
you believe to be true. You then pass the result to a method that communicates a test
result to the framework, most commonly the assertEquals method. The
assertEquals method takes as parameters the expected and actual values and, for
floating-point numbers, a tolerance value.
Search WWH ::




Custom Search