I have many tests which depend on stochastic procedures. Rarely, the tests fail, as you basically get unlucky with the random numbers.
However, sometimes the failure is actually a bug, and I'd like to reproduce it. I have a global random generator that seeds everything else. I'd like for Boost Test to output its original seed in case any test case fails.
The closest thing I found would be to output the original seed in a Fixture, but it seems I'd have to print it all the time, rather than just on failure. Is there a simple, concise way to print a statement in case any test fails?
I think I managed to find a solution, where I use a Visitor (courtesy of this answer) to figure out whether all test cases have passed, and if not print my needed info.
Note that to print I use
BOOST_CHECK_MESSAGEbecauseBOOST_TEST_MESSAGEdoes not show up in the output unless--log_level=messageis specified.If anybody can figure out a better solution I'm all ears :)