How to send custom message in Google C++ Testing Framework?

后端 未结 6 1754
闹比i
闹比i 2020-12-22 20:59

I use Google C++ Testing Framework for unit testing of my code. I use Eclipse CDT with C++ Unit testing module for output analysis.

Previously I used CppUnit it ha

6条回答
  •  -上瘾入骨i
    2020-12-22 21:23

    There is a quite simple and hacky way for doing it (without need of diving into internal classes or creating new custom classes).

    Just define a macro:

    #define GTEST_COUT std::cerr << "[          ] [ INFO ]"
    

    and use GTEST_COUT (just like cout ) in your tests :

    GTEST_COUT << "Hello World" << std::endl;
    

    And you'll see such result:

    Credit goes to @Martin Nowak for his finding.

提交回复
热议问题