You are here

Unit Testing with JUnit in DrJava

15 January, 2016 - 09:02
Available under Creative Commons-ShareAlike 4.0 International License. Download for free at

Object oriented systems derive great complexity through the interactions between the objects in the system. It is often impossible to test the entire range of the total complex behavior that a system is designed to exhibit. What one can say however is that if any given part of the system does not perform as desired, then one can make no assurances whatsoever about the integrity of the system as a whole. Thus the testing of these smaller parts, or "units" is a crucial element of developing any large-scale OO system. A unit test is a complete test of a small, atomic sub-system. Note that this is not the same from a partial test of some aspect of the whole system!

Unit tests are often performed at the individual class level, meaning that a test class that runs all the complete battery of tests on the tested class, is written for each class to be tested. In some cases however, certain systems of classes are not divisible into isolated, atomic units and in such must be tested as a whole. The key is to test as small a piece of the system as possible and to test it as thoroughly as possible.