Unit Testing

By Ivan Gevirtz

created: Tuesday, October 11, 2005
updated: Monday, January 07, 2008

Unit tests are the CONTRACT for what you're doing.  Test first is a way to understand the problem, and is an intimate part of design.  Design your unit tests and you've designed what your solution must do.  For testing, err on the side of coverage.  Cut and paste code is OK for tests -- brittleness is not a problem with test code, because we want it to break when things change!

Unit tests

We will use CppUnit for our unit testing tool.  It is the C++ port of the canonical JUnit.  It is powerful, yet relatively simple to use.  My initial plan is to incorporate this toolkit and its own unit tests into our current repository.  Then I'll write unit tests for the CRUSH project to prove it's incorporated and provide a sample.  I'll add the unit test as a post-build event, so it gets launched every build and errors break the build. This will allow our automated build system to work with this new functionality without needing to change anything!