Test Desiderata

Kent Beck on 2019-10-18

System under test

Go placidly amid the noise and haste, and remember what peace there may be in silence

Recently, I published this tweet:

Tests should be coupled to the behavior of code and decoupled from the structure of code. Seeing tests that fail on both counts.

I thought this property of tests was obvious and widely understood, but the tweet blew up. I have seen tests which are just a horrible syntax reiterating exactly what is already said in the source code under test. I went and re-read TDD: By Example and these properties are nowhere to be found, so I guess I shouldn’t have been surprised.

The experience got me thinking about the other properties of tests that I take for granted. Here, then, is a list of properties of tests. Not all tests need to exhibit all properties. However, no property should be given up without receiving a property of greater value in return.

Properties

Combinations

Here are some attractors in the space of all possible tests:

So What?

Look at the last test you wrote. Which properties does it have? Which does it lack? Is that the tradeoff you want to make?