Unit Testing: an overview

What a unit test is, and why small classes with clear responsibilities can be tested on their own.

Novice · Unit Testing · Updated

As we noted in the previous section, testing has always been important in software development. Even as early as the 1960s and 1970s, it became apparent that it was important to isolate and test individual modules of code. However, the concept of unit testing was not formalized until the 1990s when object-oriented programming became popular.

With OOP, we break our application into classes from which we create objects at runtime. The application class manages the application's flow and is dependent on other objects to do the work needed for it to run correctly.

An application uses objects

Classes are written to be units of logic that have specific responsibilities. One reason they are written this way is so that they can be tested independently of other objects.

Key terms