Almost every automated test framework has the ability to run the tests in random order and some even do it that way by default. If you aren’t already running your tests in random order then start now. You’ll be amazed at what problems this will uncover.
There are two main types of problems that will be uncovered with this approach.
- Tests that are order dependent (i.e. test A must run before test B).
- Tests that don’t clean up after themselves and leave the environment in an inconsistent state. This can cause other tests to fail because the environment was wrong, not because there was anything wrong with the code under test.
It’s worth calling out that this tip is most likely going to uncover problems in your test suite, not in your production code. Problems still need to be fixed anyway, regardless of where they are.