The unit in unit testing

Surely, everyone talks about the same unit in the context of unit testing, right?

It may be that the world hasn’t completely agreed on it yet.

There are likely two main religions about the unit. The first group, let’s name them as the ideologists, believe that the unit is always the absolutely smallest unit that can be tested. This means that unit means a function or a method1.

The second group, let’s name them the pragmatists, consider that the unit means the smallest usable unit in the system. This means that the unit is more of a component or a module – a larger entity than a function or a method.

But do the religions matter in the end?

They may – while the ideologists are testing the implementation of a function with unit testing, pragmatists are testing behavior of a component with unit testing.

  1. Or a term of your preference ↩︎