Avoiding Future Defects and Documenting Codes
Explore how test-driven development (TDD) helps prevent future defects by keeping tests as regression suites that provide fast feedback and confidence. Understand how TDD tests serve as up-to-date documentation by closely aligning with code, enabling teams to safely add features and maintain agility in evolving software projects.
Growing code in development can cause major defects in future productions if proper protection measures are ignored. Let's examine how we can protect our code from future major defects.
Protecting against future defects
As we grow our code by writing tests first, we could always simply delete each test after it has passed. We’ve seen some students do that while teaching them TDD because we hadn’t explained that we shouldn’t do that yet. Regardless, we don’t delete tests once they pass. We keep them all. Tests grow into large regression suites, automatically testing every feature of the code we have built. By frequently running all the tests, we gain safety and confidence in the entire code base.
Adding new features
As team members add features to this code base, keeping all the tests passing shows that nobody has accidentally broken something. It is quite possible in software to add a perfectly innocent ...