I've used both CppUnit
and boost::test
for C++ unittesting. Generally I prefer boost::test
, mainly because the auto-test macros minimise the effort to setup tests. But there's one thing I really miss from CppUnit
: the ability to register your own "protectors", instances of which automatically wrap all the run tests. (Technically, you install a test "listener", and that can wrap each test in a protector scope).
I've found these invaluable in the past for monitoring unittests for unexpected side effects (e.g checking code hasn't changed the floating-point unit state flags). I can't see any equivalent in the boost::test
documentation, although BOOST_FIXTURE_TEST_CASE
maybe comes closest.
Any suggestions for how to best achieve the same thing as CppUnit's protectors in boost::test
?
(I haven't really looked into boost::test
's implementation yet, but if it's anything like CppUnit
it must use something very like protectors itself).