NoTrust
NoTrust

Reputation: 207

CppUnit: How to print failure details immediately

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?

Upvotes: 0

Views: 241

Answers (1)

John Deters
John Deters

Reputation: 4391

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().)

Upvotes: 0

Related Questions