A copy of Emily Bache's tire pressure kata, part of the so-called racing car katas.
The idea is to test whether or not the alarm goes off whenever the tire pressure happens to go beyond the (hard-coded) boundaries.
There are almost countless ways of approaching this task/kata. Some possibilities are mentioned below.
The peel strategy is explained by Emily Bache (www.sammancoaching.org).
The slice strategy is explained by Emily Bache (www.sammancoaching.org).
The ports & adapters approach can frequently be used in these kinds of situations.
If we allow ourselves to modify the code, we can create an interface for the tire pressure sensor and have the alarm class depend on that interface instead of the concrete sensor class. The interface can then easily be stubbed.
For dynamic languages, we can use monkey patching.