3 ms·
I heartily agree with your general sentiment, but think you're not mentioning a very important function of a test suite which is: c) explicitly and accurately
by seanhunter 5y ago
I heartily agree with your general sentiment, but think you're not mentioning a very important function of a test suite which is:
c) explicitly and accurately document expected behavior including in a variety of edge cases
...this is sort of implicit in your first 2 but I think worth breaking out.
Going for high test coverage (in places where I've done TDD-style dev) has really forced me to think through those edge cases and what I want my code to do in all of them.
I think negative-value testing comes from the mindset of "how do I write a test which exercises this branch?" but a positive version of that is "I put this branch to handle the case where foo is getting close to the boundary. Let's put in test cases with foo at and close to the boundary and make sure it does what it is supposed to." If the test focuses on behavior then you find the bugs and enable refactoring and you get high coverage because if you can't exercise all the paths probably some of them are dead and can just get deleted.