Member-only story
Improve Your Testing #18: Make Your Tests Fast
Testing time isn’t just a number, it affects your daily work.
In this series of articles, I’ve talked a lot about how to do testing, how to improve, and how to write better tests. And above all, the cornerstone has often been “Readability is everything.” Well, it’s time to add the second rule: “Unless they take too long”. Tests must be fast, very fast. But what happens then with readability? Or what happens with integrated tests? All of this is what we’ll look at in this installment.
Why fast tests?
How do we know the code works? Without automatic testing, we have to open it, run it, check if it works, and then consider it good to go. And this process is already slow, so if it doesn’t work, we have to investigate what failed and start over.
When we have tests, many times all we need to do is run the tests, check that they all pass, and we can continue. But obviously, even if all tests pass, we’ll probably want to run it manually to be sure, but: a) we’ll likely find things that fail when we run the tests, accelerating the cycle, and b) we won’t need to be so thorough in manual testing, because many things will already be clearly covered.