Back in the day I used to say this about test-driven development:
If ever I get a surprise, it means I have a missing test.
That is, if I’m in the GREEN or REFACTOR step of the TDD cycle and my changes make something else break, I need to add a test to document something that I must have missed previously.
I don’t think that now. These days I am much more likely to say something like:
If ever I get a surprise, it means I have accidentally discovered some connascence that I was previously unaware of. I need to eliminate it, weaken it, bring the connascent code closer together, or refactor my names so that it is clearly documented.
I’ve discovered some refactoring that needs to be done, and I wouldn’t necessarily rush to add tests.