What are the most modern approaches to unit testing for the C++ language? The class of the languages with bigger introspection power (like Python) have unit testing fra
The only test framework worth considering: Catch
For an introduction to the lib, see also here and here
It's easy to use (a header-only lib consisting of just one header), portable, and has by far the simplest, cleanest syntax of any C++ unit testing framework.
And unlike other libraries, you don't need to remember two dozen different macros f or different types of assertions.
You just use REQUIRE:
int one = 1;
REQUIRE( one == 2 );
which, through some clever operator overloading, will show both the original expression and the expanded argument values in the output:
test.cc(7): FAILED:
REQUIRE( one == 2 )
with expansion:
1 == 43
Compared to this, every other framework is a chore to use IMO.
I used to use Boost.Test before I found this, but that was a lot more cumbersome to set up and use. We use CppUnit at work, and that seems to be designed to be as fragile and painful as possible.
I've looked briefly at the VS2013 test framework, but haven't tried it, and it looks tolerable, but very much like it's emulating "the old guard". It doesn't really try to be cleaner, easier or better than CppUnit, Boost.Test and all the other ones that came before Catch. So I'd say don't bother with it. Tests should be easy to write (and to understand), and Catch is lightyears ahead of every other framework I've seen on that front.
I've been using theVisual Studio 2013 built in test framework for about 6 weeks now and really like it. The integration is excellent and it's very easy to pick up. If you're working on a project that only targets Windows then I thoroughly recommend it.