Search code examples
c++eclipseconsolegoogletesteclipse-mars

How to have Eclipse console show the same GoogleTests output as in the terminal?


I use GoogleTest extensively and the output in the cosole looks like this:

GoogleTest console output

When I run the same from within Eclipse (using Eclipse Mars latest as of today) I get the following output with no colors and junk characters (are not visible just pasting the output here):

Running main() from gtest_main.cc
[0;32m[==========] [mRunning 3 tests from 1 test case.
[0;32m[----------] [mGlobal test environment set-up.
[0;32m[----------] [m3 tests from NloptAdapterSuite
[0;32m[ RUN      ] [mNloptAdapterSuite.testQuadraticFunction1
[0;32m[       OK ] [mNloptAdapterSuite.testQuadraticFunction1 (1 ms)
[0;32m[ RUN      ] [mNloptAdapterSuite.testQuadraticFunction1WithNoise
[0;32m[       OK ]     [mNloptAdapterSuite.testQuadraticFunction1WithNoise (1 ms)
[0;32m[ RUN      ] [mNloptAdapterSuite.testQuadraticFunction2
[0;32m[       OK ] [mNloptAdapterSuite.testQuadraticFunction2 (1 ms)
[0;32m[----------] [m3 tests from NloptAdapterSuite (3 ms total)

[0;32m[----------] [mGlobal test environment tear-down
[0;32m[==========] [m3 tests from 1 test case ran. (3 ms total)
[0;32m[  PASSED  ] [m3 tests.

How can this be fixed to have the same output?


Solution

  • The ANSI Escape in Console plugin that greg-449 linked above worked great for me. After installing it, the gtest output looks like:

    gtest console output

    I'm on Neon.2 (Eclipse 4.6.2).