CppUnit: How to print failure details immediately

207 Views Asked by At

I use the following code to run CppUnit tests:

CppUnit::TextTestRunner runner;
CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest(registry.makeTest());
bool result = !SehSafeTestExecutorCPPUnit::Execute(runner);
return result;

It prints dots and 'F' but the details on each error are printed afterwards. Is it possible to print details on fails immediately like it's done in gtest?

1

There are 1 best solutions below

0
John Deters On

You can derive a custom class from TestListener, and implement your custom reporting in endTest(). Don't forget you have to add your custom TestListener to your TestResult.

If you're only interested in the instant reporting of failures, you can create a custom TestResultCollector and overload addFailure() with a call to your own output (don't forget to call the parent addFailure().)