visual-studiomicrosoft-cpp-unit-test

Way to print message to debug output with Visual Studio CppUnitTestFramework


Is there a way to print messages to output window with CppUnitTestFramework in Visual Studio.
There is TRACE() function to display messages from program in the debugger Output window in MFC.
I want to know whether that kind of function exists or not with CppUnitTestFramework.


Solution

  • The Logger class in the CppUnitTestFramework namespace has two simple functions for this:

    Logger::WriteMessage(const wchar_t* message);
    Logger::WriteMessage(const char* message);
    

    In the VS IDE, the output can be seen in the "Tests" console output window and can also by clicking the "Output" link seen in the detail panel at the bottom of the Test Explorer.

    On a build server the message will appear in the log for the test phase.