Magic principles in test automation: Clarity

automation testing magic
Reading time: 1 minute, 49 seconds

Since I have been an amateur magician for the last 34 years, this subject naturally influences my thinking on software. This post will kick off a little series on magic principles in relation to test automation.

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:

  1. a playing card is chosen and lost in the deck
  2. the magician finds it in a flash of fire
  3. the rest of the deck vanishes along with the spectator's watch
  4. the chosen card changes color
  5. 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:

  1. a playing card is chosen and lost in the deck
  2. 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.

Previous Post Next Post