ZeroCool940711 / Sandbox-Game-Engine

GNU General Public License v3.0
4 stars 1 forks source link

Replace CppUnitLite2 with another C++ unit testing library. #32

Open ZeroCool940711 opened 5 years ago

ZeroCool940711 commented 5 years ago

CppUnitLite2 is an old unit testing library from 2005, there are a few other modern libraries that would do the same but better. Here are some of those libraries with information taken from a reddit post where people were talking about this topic:

* Catch:
    Header-only.
    Supports unit-tests with bdd style (in this style you do not need fixtures anymore).
    Easy to get started.
    Does not support mock objects.
    One single REQUIRE macro for almost any comparison. Easy to use.

* Boost.Test:
    Supports data driven tests since 1.60 (if I do not recall incorrectly). Very useful for random testing generating data.
    Since 1.60, supports single BOOST_CHECK macro, same as CATCH.
    No support for mock objects, though you can use boost.turtle. I used it together with boost/catch and it did a good job.
    Supports header-only and library variants. You should use library variant in general.

* Google Test:
    Supports death tests (tests that would break the machine, such as segfaults).
    Comes with google mock. You have mocking out of the box.
    Does not support C++11 move semantics. I recall this was annoying at some point for my testing.
    Must embed in your project as a source to compile with the rest of your code.
    Many different macros. You have to remember a bit more than with Boost.Test and Catch in this area. Not a problem, though.

All 3 frameworks support automated test registration. I would recommend any, but if you want a full solution and do not need random tests, I would go for google test. If data-driven testing is useful to you, you can use Boost.Test + Boost.Turtle. Catch is more beautiful, but also more lightweight, consider it if you just want to use a bunch of unit tests. It does the job well. I even integrated it with Boost.Turtle at some point, but was a bit of a pain.