Testing Around the Untestable

Some parts of a codebase are practically impossible to test. Platform UI controls, for example, often lack the hooks needed for automated tests, or make them so costly—complex setup, special frameworks, slow runs—that the effort isn’t worthwhile. Any real logic sitting inside those elements is a breeding ground for bugs and a barrier to change.

The Humble Object pattern offers a way around this: strip the hard-to-test component down to a bare minimum of behavior, and move as much logic as possible into surrounding code that is easier to exercise. The name comes from an article by Michael Feathers; the approach itself is closely tied to UI patterns like Presentation Model (MVVM) and Passive View, where the view is intentionally dumb and the model carries the real work.

In practice, the "humble" object becomes a thin shell responsible only for whatever must happen in the untestable environment. Everything that can be pushed outward—state changes, validation, event handling—belongs in testable objects. This doesn't eliminate the untestable component, but it shrinks the surface area where bugs can hide undetected.

For a more thorough treatment, including variations and concrete examples, Gerard Meszaros covers the pattern in depth in his xUnit Test Patterns book; the Humble Object entry is available online.