4 ms·
I used to oppose unit testing because I had a good C++ compiler with all warnings turned on and I foolishly thought that was all I needed and that unit testing
by 16s 15y ago
I used to oppose unit testing because I had a good C++ compiler with all warnings turned on and I foolishly thought that was all I needed and that unit testing was only for dynamic languages that did not have compilers.
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.
- franklindholm 15y agoI 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 :)
- 3wetwetw 15y agoC++ 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).