Common complaints and problems that I've both encountered and hear other developers raise when it comes to the practice of Test Driven Development are:
- Impossible to refactor without all the tests breaking
- Minor changes require hours of changes to test code
- Test setup is huge, slow to write and difficult to understand
- The use of test doubles (mocks, stubs and fakes is confusing)
Over the next three posts I will demonstrate three easy steps that can resolve the problems above. In turn this will allow developers to gain one of the benefits that TDD promises - the ability to refactor your code mercifully in order to improve code quality.
- Stop Making Everything Public
- Limit the Amount of Dependencies you Use
- A Unit is Not Always a Method or Class
Code quality is a tricky subject and highly subjective, however if you follow the three guidelines above you should have the ability to radically change implementation details and therefore improve code quality when needed.