Java Reference
In-Depth Information
Figure 13.4
The CoreTest running a suite of tests
One last example is the
SAMoneyTest.java
file that was used in the
CoreTest
example (Figure 13.4). Did you notice the names displayed in the
test hierarchy? They don't match the method names used to run the tests in
SAMoneyTest.java
because we constructed the suite “by hand” instead of
letting the JUnit introspection and reflection find the methods dynamically.
Such manual approach has some advantages. You can restrict the current
set of tests being executed to a subset of the entire set of tests. You can also, as
this example shows, give other names to the tests. The biggest drawback,
though, is the maintenance cost of having to add the test by hand to the
suite()
method whenever you add another test method.