One test to rule them all

To test a unit thoroughly1, one has to throw different sort of things at the unit to make sure it behaves well in different situations. Throw it with some – or all – normal things, with a bunch of abnormal things, and finally with a few why-on-earth-would-you-do-that things to see how it reacts.

With all of the possible permutations, it’s tempting to write one or a few unit test that tests everything in the unit. They may be slightly complicated, but loops are cheap and copy-pasting is boring. The “master unit test” is born. One test result per unit is enough.

Before doing so, don’t. Separating the permutations to different tests will be helpful in the longer term.

  1. or at least try to ↩︎