3

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.

Hill
  • 3,391
  • 3
  • 24
  • 28
  • Possible duplicate of [How to get console output in Visual Studio 2012 Unit Tests](https://stackoverflow.com/questions/16815804/how-to-get-console-output-in-visual-studio-2012-unit-tests) – Brian Jun 27 '18 at 18:54

1 Answers1

2

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.

Chris Olsen
  • 3,243
  • 1
  • 27
  • 41