The High-Performance guideline
Your unit tests should not take, in today’s hardware, over 5 seconds to run, ideally no more than a couple of seconds after the tests are loaded. But why all this fuss? Can’t we just let them take whatever time is needed to run without sweating over it?
First, your unit tests will have to run many times throughout the day. TDD is about running a chunk of your unit tests or all of them with every change; therefore, you don’t want to spend your time waiting and lose valuable time that could be spent more productively.
Second, your unit tests need to provide fast feedback to your CI pipeline. You want your source control branches to be green all the time, so that other developers are pulling green code at any given time and, of course, it is ready to ship to production. This is even more important for larger teams.
So, how do you keep your unit tests performing as fast as possible? We will attempt to answer this question in...