Protecting against future defects
As we grow our code by writing tests first, we could always simply delete each test after it has passed. I’ve seen some students do that when I’ve taught them TDD because I 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.
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 change somewhere, only to find that some seemingly unrelated thing has now stopped working. This will be because of the relationship between those two pieces that we previously did not understand.
The tests have now caused us to learn more about...