Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing additional output in Google Test

Tags:

c++

googletest

I'm using the googletest C++ testing framework. Normally the textual output of running a test looks like this:

 [ RUN      ] MyTest.Fuzz [       OK ] MyTest.Fuzz (1867 ms) 

I would like to output some additional data in the same format, for example:

 [ RUN      ] MyTest.Fuzz [          ] random seed = 1319760587 [       OK ] MyTest.Fuzz (1867 ms) 

I have found Logging Additional Information in the googletest documentation but that only seems to send structured data to the XML output, not the standard console output.

Is there a googletest function I can call inside my unit test that outputs text in this format? Manually sending data to cout works, but it doesn't include the usual coloured output so I have to explicitly indent the output by printing 13 spaces or whatever.

like image 394
Greg Hewgill Avatar asked Oct 28 '11 00:10

Greg Hewgill


1 Answers

Simply printing to stderr will work in the default test configuration.

std::cerr << "[          ] random seed = " << random_seed << std::endl; 
like image 77
Martin Nowak Avatar answered Sep 16 '22 12:09

Martin Nowak