Improve Your Testing #12: The F.I.R.S.T. Principles
There is a simple acronym that helps you to checklist your tests.
In previous articles, I had already hinted at some properties that all tests must fulfill; however, given their importance, there is an acronym that encompasses the most important properties.
Starting from the beginning
FIRST is undoubtedly a wordplay; besides being an acronym for the properties to be met, it’s also an indication of when to do it. Therefore, in addition to being an acronym, it tells us that tests should be done first, before the code.
It’s easy to argue that this requires doing TDD, but it doesn’t have to. Starting to write the test at the beginning has the main objective of truly focusing on what we want to do. Therefore, before starting, it asks us to study the problem, try to understand it, and attempt to establish a series of goals we want to achieve. This doesn’t have to be code; it can be paper, it can be a checklist, and if we think about it carefully, it’s nothing more than a more in-depth decomposition of the problem to ensure we’ll address everything we want to address.
And once done, which tests will we write? Well, those that verify that the objectives are met. This gives us a guide.