Next page | Contents page |

Unit testing with JUnit and EasyMock

This section is not part of Java SE but it is supported as standard by the IDEs (Eclipse, NetBeans) and most people use these techniques. It is important to do unit testing before going on to integrate systems.

Why "Unit" testing?

It's all about testing one Java source file in isolation. That usually means a single Java class. Tests involve objects of the class under test but no objects of other classes (that would be integration testing). We may have to pretend that other objects exist - as stubs or mocks - in order for methods of the object under test to do their work.

We aim to exercise every line of the class under test.

We aim to make tests that can be run automatically on a routine basis, to check regularly that the class still works (no-one has modified and broken it).

Next page | Contents page |