1.5. Collecting Data From Testing Frameworks

When you run unit tests it may be convenient to send the trace and error messages to the same destination as the other debug messages. This way all information is in one place. And you have all the messages in the same order as the program flow

1.5.1. CppUnit

One of the well known frameworks for unit tests with C++ is CppUnit. To forward the messages you need to replace the default test listener for standard output. The following source fragment sets up the environment for log4sendpp and registers the new test listener:

  l4snd::Logger &logger = l4snd::Logger::logger();

  runner.eventManager().addListener(new l4snd::CppUnitListener());

See log4sendpp/tests/log4sendpp_test.cpp for the main part of the according test files.

Location information from CppUnit come with level TRACE and messages due to failures with level ERROR.