26 ms·
Also, it's important to remember that tests are code too. A test needs to stand the test of time just as code does--if the tests are too brittle then you're ju
by dasil003 18y ago
Also, it's important to remember that tests are code too. A test needs to stand the test of time just as code does--if the tests are too brittle then you're just creating busy work.
However people who haven't tried methodologies like TDD or BDD shouldn't parrot this as justification for not writing tests. First you need to learn how to write tests, and how to write more testable code. Test-first is invaluable training for developing these skills.
Once you have that experience you are better qualified to decide what constitutes useful testing. Frankly, I find the most value comes from basic sanity tests. Testing obscure edge cases of algorithms is often times not worth it because the mistake is made once and corrected. Having the test case is good (especially if written up front as an excercise in specification), but in many cases the chance that these things will break once fixed approaches 0.