3 ms·
I think the article is fine as written, but in the interests of expanding on its ideas, I submit that writing tests first is a design technique and maintaining
by raganwald 15y ago
I think the article is fine as written, but in the interests of expanding on its ideas, I submit that writing tests first is a design technique and maintaining substantial test coverage is a regression-proofing technique. Both also serve as documentation.
I mention this, because these three objectives--design, regression-proofing, and documentation--can be achieved in various other ways besides writing tests first, and it can be helpful to separate them in your mind even if you choose to practice TDD with great discipline.
- stonemetal 15y agoI always hear that TDD is good for documentation, but most of my unit tests cover odd corner cases, weird error conditions and the like. It certainly isn't a show of what to do. What do you do with your unit tests that make them high quality documentation?
- mononcqc 15y agoThat's often true of tests that were only used to check the validity of code, not its design. In many uses of TDD, you will use somewhat broader specifications to test things. "The login system accepts any user with a valid name by returning '1' and returns '0' if the password isn't the right one". You can have a test to verify that without using special corner cases, and a test such as this one will likely look like any other normal use of your library or function. If you develop all your requirements using TDD, then both the corner cases and the standard cases should be sitting in the test suite. The standard cases can act as documentation and a design tool while corner cases are really more there to insure things work absolutely right.