The Search For A Simple C++ Unit Tester

The Problem

I want to find a generic unit tester for c++ programs, for use as a teaching tool. It needs to be lightweight so it doesn’t detract from the actual assignment and easy to use so that it can be picked up quickly by someone new to c++.

I also found this page with a great comparison of C++ Unit Testers for those who want a feature-rich, yet simple tester.

The Rankings

This page will be my summary page, with links to individual pages on any tools that I download and test.

Tool Ranking (1-10) Reasons
cutee 4 Looks useful, but won’t compile
EasyUnit 7 Clear reporting format and test building syntax. Very simple, but perhaps too simple? Little to no documentation.
CUTE 6 Cluttered output and framework. Allows for more variability in test creation. Great documentation!
Boost Test 9 Clear, but not attractive, reporting format. Great test building syntax. Allows for helper functions, and is well documented and supported. Takes a long time to compile.
C++ Unit Lite 2 Documentation is not enough to compile the library, let alone the examples.
UnitTest++ 9 Clear, but not attractive, reporting format. Great test building syntax. Allows for helper functions, and is well documented and supported.
GoogleTest 9 Great syntax, lots of functionality, good output. Requires fair bit of background work with Makefile

Summary

Clearly, my favorites were BoostTest, UnitTest++, and GoogleTest. They all have very similar coding syntax, with very little hassle to add new tests (although GoogleTest clearly wins here for having the most useful ASSERT macros). BoostTest and UnitTest++ have nearly identical output formatting, which was concise and boring. GoogleTest gave more output than strictly necessary, but with the color coding it was actually nice to read. GoogleTest and UnitTest++ require the creation and linking of libraries, while BoostTest is just a bunch of macros (and thus takes a long time to compile).

So, of course, the final decision comes down to what is most important: functionality or ease of integration (including compilation effort and/or compilation time). For teaching purposes, I think a Makefile could be provided to the students to compensate for library linking complications, so I will probably go with the added functionality of GoogleTest. With more ASSERT options, a wider variety of tests are available for exploration. Plus, the output comes out in color. How can you beat that? 😉

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to The Search For A Simple C++ Unit Tester

  1. Have a look at Catch, I ditched all of the above when I found it. Behavior driven feels very natural, single file to include, low overhead… a gem ! https://github.com/philsquared/Catch

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s