Clone wiki

xUnit++ / Compare

How does xUnit++ compare to ...?

xUnit++ is far from the only unit testing framework for C++, and is certainly not perfect. However, it stands up quite well when compared to other systems. Most systems utilize preprocessor macros to implement a small subset of checks, and most also require you to provide your own test runner. Perhaps most importantly, only xUnit++ uses std::async to run tests concurrently!

xUnit++Boost UTFGoogle TestMSTestUnitTest++
ImplementationStatic LibraryAny! (See Note 1.)User-provided (See Note 2.)Requires Visual Studio 2012+Static Library
Test ImplementationMember functionsPreprocessor macrosPreprocessor macrosStatic member functionsPreprocessor macros
Test RunnerProvidedUser-suppliedUser-suppliedVisual StudioUser-supplied
ThreadingUses std::async to run tests concurrently!n/an/an/an/a
Per-Check MessagesUse an overloaded stream operator.
Assert.Equal(a, b) << "message"
Append _MESSAGE to any check macro.
Use an overloaded stream operator.
ASSERT_EQ(a, b) << "message"
Additional parameter
Assert::AreEqual(a, b, "message")
LoggingLog.<level> << "msg" << value;BOOST_TEST_MESSAGE("msg" << value);n/an/an/a
AttributesUp to 8 per test.n/an/aUnlimited per module, fixture, or method.n/a
Timed TestsHalt long-running tests.n/an/an/aFail tests that went over time limit.

Note 1: Boost has just about every implementation you could ask for. If your test library is small and simple, you can just include a single header file, or you can link it as a static library, or you can reference it as a dynamic library.

Note 2: Google Test requires most users to create a project to build the test executable. Some projects are provided, but several are out of date.

A note on Test Runners: With the exception of MSTest, the other test frameworks require implementing (in some fashion) int main(). xUnit++ prefers to instead offer standard test runners that know how to run your tests for you natively.