Why write a failing 🔴 test?

We all know red, green and refactor technique. But I was never convinced that I should write a failing test first. I thought — “Why would I fail my test?”. So here is my story on how I learnt it the hard way. That was a time when I lost all my confidence. I wish — nobody has to go through the same in their life.

My Role in the team

The Task

After investing two weeks and being in dilemma — to ask for help or not, I thought to consult one of the QAs. He told that it was a valid failure. The test broke because really the baseline is very old and the application’s UI has changed a lot.

The New Task

I was happy and sad, both at the same time. Happy — because I did setup the machine correctly. Sad — because I lost confidence in the tests that we had. How could we have not figured out that we had a test, which tests nothing at all. Every time we checked in code, we ran the tests and it went green. Nobody thought that while having so many changes in the application’s UI , some or at least one visual comparison test should definitely fail. For months, no one had any suspicion.


While setting up a machine, we always installed the latest version of the ImageMagick. The existed CI machines had older version of ImageMagick which was latest at that point of time when the machines were setup. The one I recently setup had the newer version of ImageMagick. Hence the tests were actually testing and then failing only on the machine under inspection (i.e. the machine which I was testing).


Image Source



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store