3 ms·
/me raises hand on the pro-testing side I've been programming for a living since 1996, and only recently started to do TDD in the normal sense of writing unit
by circlefavshape 9y ago
/me raises hand on the pro-testing side
I've been programming for a living since 1996, and only recently started to do TDD in the normal sense of writing unit tests before writing code. I've found to it to be an enormous help with keeping my code simple - the tests or the mocking getting difficult is a great indicator that my code can be simplified or generalised somehow
I argued for functional instead of unit testing for years, but it was only when a team-mate convinced me to try unit testing (and writing the tests FIRST) that the scales fell from my eyes. Unit testing isn't really testing, it's a tool for writing better code.
BTW from an operational perspective I've found it's most effective to insist on 100% coverage, but to use annotations to tell the code coverage tool to ignore stuff the team has actively decided not to test - much easier to pick up the uncovered stuff in code review and come to an agreement on whether it's ok to ignore
- saltedmd5 9y ago+1 - speaking as an ex-sceptic, the only people I know that don't like unit testing and/or TDD are the people who either misunderstand their purpose or have not learned how to utilise them properly yet. Once TDD "clicked," the quality of my code shot up very rapidly indeed.
- misja111 9y agoI agree that TDD and unit tests can help you when writing code. But once your code has been written, are all those unit tests still useful? Or do they get in your way when you do large scale refactoring? I have seen quite a few codebases with loads of unit tests that might once have been useful, but now were just slowing down development. Many of them should have been thrown away and replaced by a couple of functional tests, however the sunk cost fallacy always kicked in, nobody wanted to throw away all the hours of work that had gone into making them and not to forget the precious code coverage as well.
- circlefavshape 9y ago> nobody wanted to throw away all the hours of work that had gone into making them This is a REALLY common developer attribute that drives me nuts - people don't want to throw away stuff that they put a lot of effort into.
- mdpopescu 9y ago> But once your code has been written, are all those unit tests still useful? The reason for this question is the naming mistake that was made in the beginning. They are not TESTS, they are SPECIFICATIONS. Once your code has been written, are the specifications still useful? Well, duh... unless the business has changed them then yes, they're still useful.