CxxTest for unit testing C++ programs

I just discovered CxxTest, and just had to mention it. Fantastic unit test framework for C++ programs. To brush up on my C++ coding, I decided to write a simple 6809 CPU emulator, with the goal of being able to plug-in other CPU’s. This project really lends itself to the idea of unit tests. It’s very easy to test each part of the emulator, and check the results after an instruction has run.

After reading @noel_llopis‘s article¬†Exploring the C++ Unit Testing Framework Jungle I figured I would check out CppUnit first, since I had seen it mentioned it was¬†the standard on, or at least widely used. Not sure how that is possible, given the weak documentation and complicated setup. The docs never once tell you what to include and what to link against. 30 minutes later I decided to move onto CxxTest. Glad I did as CxxTest was very simple, and I had unit tests running within 5 minutes. The true mark of a well setup project. My emulator processed it’s first instruction today, LDX #$1234. And the unit tests were right there to validate the results.