Make Tests Repeatable and Independent

In TDD, we want to run the tests frequently. When we do so, it shortens the pulse of our work, increasing velocity. Also, when a test unexpectedly fails, we know that it must be something we just did that produced this result. It becomes very easy to find the error.

This means that we must be able to run tests frequently which in turn means that tests:

  • Must run fast.
  • Must be able to run at any moment.

The first point is the topic of my next post.

The second point requires that the tests can be run without any specific preconditions on the system. No test should require a specific time of day, a specific location in the world, a specific condition of the database, UI, or other system element, or indeed anything that would limit developers from running tests whenever they desire, almost as a reflex.

Tests should feel like they cost nothing to run. In truth, nothing costs nothing, but the cost of running tests should be so low that developers don’t hesitate to run them frequently.

In other words, tests should be repeatable and independent. To achieve this, developers must be well trained in good test design, the separation of concerns, and strong techniques like mocking, shunting, endo-testing, dependency injection, and so on.

This is Scott Bain. Visit us at

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.