Magic principles in test automation: Clarity
There are many so called "rules" in magic, for example
- you should not reveal your secrets
- only show effects that you practiced
- never tell the audience what you will do next
But one seemingly simple rule that is very important for spectators is "Keep your effect clear".
Throughout magic literature, one finds a lot of tricks that have multiple phases, surprises (magicians refer to them as "kickers") and different kinds of effects.
A (slightly over exaggerated) example could be:
- a playing card is chosen and lost in the deck
- the magician finds it in a flash of fire
- the rest of the deck vanishes along with the spectator's watch
- the chosen card changes color
- a chicken appears wearing the watch around its neck
As fascinating as this would be, there is a problem with that - it is way too hard to follow and digest.
Compare this with just the first two phases of the effect:
- a playing card is chosen and lost in the deck
- the magician finds it in a flash of fire
Much clearer, isn't it?
The same rule applies to software testing.
Of course, it is possible to cram a lot of test steps into a scenario. This might even be desirable in some cases, e.g. when testing a complex user flow.
However, keeping your tests compact will have some benefits:
- Clarity: The viewer of your test results can grasp immediatelly what the test is about.
- Cause & Effect: It is easy to see what preceded a failed assertion.
- Boredom: Going through 100 steps every time there is a failure is a time-sink.
- Attention span: Keeping focus while scanning the test results is easier.
Dai Vernon (aka "The Professor), one of the greatest sleight-of-hand magicians of all time said once
Confusion is not magic.
and I am highly in favor of adopting this to testing as well.
- All articles in this series
- Next article in this series: Magic principles in test automation: Misdirection