TDD is an incredibly difficult discipline to do well. Although the foundational elements of TDD are relatively simple to learn, it takes years of experience on a variety of projects to master them. The single biggest mistake a TDD practitioner can make is to not reflect upon their code with the intent to improve it after each Red-Green-Refactor cycle.
Simply applying SOLID or DRY principles will not serve a test suite in the long run. Ensuring tests remain well-named using domain concepts, compact, and read like a small story that reveals intent to the reader are critical elements of building a maintainable test suite that others want to utilize and contribute to in the long term.
One of our industry-driven insights is
TDD Gears. TDD
contains a Red-Green-Refactor cycle at its core, along with a
collection of practices and principles. TDD Gears is a model
that explains how it all fits together. There are three
forward gears and one reverse gear in TDD, as sometimes you
need to back up and try a different approach.
The low gear is used to get started and build context, the medium gear is used to enhance design and apply advanced patterns, and the high gear is used to build functionality by following existing architectural patterns and practices of the system. Reverse gear is used to get back to green after a back refactor or to help take a new approach to find the next test.