Re:The evil unit test.
by franklindholm on Monday January 30, 2012 @10:56AM
(#3529226)
I agree that Unit testing is a power full tool. But tools are just tools, and they can be misused. I see this sometimes at companies where they "make" their developers write unit tests, they are just writing them because they have to and this often shows in the quality of the tests. Everything is green in Jenkins so obviously the functional tester did something wrong :)
C++ definitely also needs unit testing - even with untestable code (even when it's bad code, though not always, it may be easier to test it using something like Isolator++, rather than rewrite greenfield from scratch).
I'm a big fan now though. If I have written code that's hard to test, I re-factor the code so that it's testable. I've found that un-testable code is generally bad code (it works OK, but is hard to modify later). I also run my unit tests during the build (right after compilation), so I know right away if something fails.
I've come to really like unit testing. I'm less afraid to change things and feel better (in general) about the quality of my code.