Java Reference
In-Depth Information
The remarkable thing about the JU nit CalculatorTest class in listing 1.4 is that the
code is easier to write than the first CalculatorTest program in listing 1.2. In addi-
tion, we can run the test automatically through the JU nit framework.
When we run the test from the command line (figure 1.2), we see the amount of
time it took and the number of tests that passed. There are many other ways to run
tests, from IDE s like Eclipse to build tools like Ant. This simple example gives you a
taste of the power of JU nit and unit testing.
1.7
Summary
Every developer should perform some type of test to see if code works. Developers
who use automatic unit tests can repeat these tests on demand to ensure that new code
works and doesn't break existing tests .
Simple unit tests aren't difficult to create without JU nit, but as tests are added and
become more complex, writing and maintaining tests becomes more difficult. JU nit is
a unit testing framework that makes it easier to create, run, and revise unit tests.
In this chapter, we scratched the surface of JU nit by stepping through a simple test.
JU nit has much more to offer.
In chapter 2 we take a closer look at the JU nit framework classes (different annota-
tions and assertion mechanisms) and how they work together to make unit testing effi-
cient and effective. We also walk through the differences between the old-style JU nit 3
and the new features in JU nit 4.
 
 
 
Search WWH ::




Custom Search