4 ms·
is anybody really doing this in the real world? it seems kind of inefficient to go through 15 testing cycles to write 10 lines of dead simple code. i like to
by unshift 15y ago
is anybody really doing this in the real world? it seems kind of inefficient to go through 15 testing cycles to write 10 lines of dead simple code.
i like to write tests before my code when i am trying to solve a specific problem, or think of a new potential issue and want to test it, but i find "pure" TDD takes it way too far. i don't see practical use in exhaustively testing every single potential case for a simple wrapper around datetime. i do like the idea for really critical sections, but it seems way overkill for most code.
TDD to me seems, like most things, as a good tool to have in the tool box, but moderation is key. articles like this are helpful to describe the practice but tend to always prescribe it for everything.
- pyre 15y agoIt depends on your use-case. If you exhaustively test something that is a simple wrapper around datetime, then you could swap out datetime with something else and still be reasonably confident that it still works (I realize that this is less likely in this example).
- tjr 15y agoI worked on a project where we did lots of unit tests along these lines. It was for an avionics networking library, where assurance of robustness is more called for than with, say, most web applications. And in general, avionics software development does feel both very inefficient and (mostly) very simple. But our customers are very happy when it doesn't crash (figuratively or literally)!
- frankwiles 15y agoDoing TDD isn't always about having 100% test coverage and as you described is often wasted. But having coverage in line with how "important/complex" that piece of code is wonderful, frees you to refactor more easily and saves you from writing throw away test code, and/or manual testing. Like most things in life, it's about moderation. Do you need 80+% test coverage on your "tweet this" feature? No. Do you need 90+% test coverage of your signup and ecommerce process flows? Absolutely! Don't get hung up writing trivial tests as you described above, instead focus on the things that really matter.