Improve Your Testing #13: When F.I.R.S.T. Principles Aren’t Enough
Because, when it is possible to do everything right, and fail, we have to change our mindset.
In the previous article, I explained the FIRST principles: Fast, Isolated, Repeatable, Self-validated, and Timely. It’s a solid blueprint for creating resilient tests, and also, as the name itself suggests, very good for beginners, for getting started. However, as we gain experience, we see that it’s possible to do everything right, and still have things not work as expected. That’s why I present a more advanced second reading of FIRST, a new mindset.
When FIRST Principles doesn’t work.
FIRST principles are a good starting point, and it establishes a series of minimum concepts to follow. These help understand testing concepts, such as how using random or date makes testing more difficult (doesn’t fulfill Repeatable) and therefore we need to look for alternatives (aka mocks).
But once these minimum principles are achieved, we might still find that the tests don’t work well. We can end up creating a very fast, isolated, and repeatable test, but despite passing successfully, the software unexpectedly fails in production.