Is there a C++ unit testing library that is similar to NUnit?

10,083

Solution 1

Expanding on Mark Bessey's answer: I really like cxxTest because it's just a set of C++ header files & Perl scripts. As long as you have a C++ compiler & Perl, it will work on nearly any system. It also has features to integrate with your IDE (although I haven't used them).

Also, here's a good article Exploring the C++ Unit Testing Framework Jungle. This post is potentially out of date (circa 2004), but gives a great summary of features & straight-up examples utilizing each of the following C++ unit testing frameworks:

  • CppUnit
  • Boost.Test
  • CppUnitLite
  • NanoCppUnit
  • Unit++
  • CxxTest

Solution 2

Have You considered using CppUnit?

Here is an overview on unit testing frameworks for C++.

Solution 3

We use Google Mock and Google Test. Having never used NUnit, though, I can't comment on how similar it is to NUnit.

Solution 4

And there's Boost.Test.

Solution 5

You won't find anything very much like NUnit, unfortunately. Since C++ doesn't have the same strong reflection ability, the process for defining tests needs to be somewhat more explicit, rather than using attributes, as in NUnit.

I like cxxtest because it's easy to set up, and doesn't require manual test registration.

Share:
10,083
A-K
Author by

A-K

Developer

Updated on August 03, 2022

Comments

  • A-K
    A-K almost 2 years

    We need to migrate a unit test harness developed with C# and NUnit to C++ running on Red Hat Linux.

    We want to minimize the efforts in migration.

    We are reading resources such as this:

    http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle

    But we don't see anything similar to NUnit.

  • Cascabel
    Cascabel over 14 years
    Yeah, I'm a little confused - cppunit is the first thing on that list you linked. cppunit and NUnit are both part of the xunit family (and both were originally ported from JUnit).