This project is read-only.

Redirect output of application

Nov 12, 2015 at 1:03 PM

First of all, thanks for the great job. I performed some tests, and this tools seems to work prety well.

I have just a small problem to integrated it to my UT framework : in some siutations, I need to get the outputs of my program in order to drive my unit tests. Would it be possible to redirect the output of the tested program to stdout of your application ?

I saw a similar post in the history, but it only led to the adding of the 'quite' mode. What would be interesting whould be to combine the 'quite' with 'redirect_output' so that the only output collected would be the one of the tested program.

Thanks in advance,

Nov 15, 2015 at 7:54 PM

Thanks for the feedback.

I am not sure to understand your point. OpenCppCoverage already redirects the tested program stdout.
> OpenCppCoverage --quiet --sources ConsoleApplication -- ConsoleApplication.exe > output.log
> type output.log
Hello world
ConsoleApplication.exe is a simple "Hello world" program. As you can see, the previous commands redirect the stdout to the output.log file and display the content.
Can you provide additional information?

Hope that help,

Nov 17, 2015 at 2:31 PM

Thanks for your answer.

I double checked my code and understood what goes wrong.

In fact, my application is providing some information on stdout, and a ruby script is driving the tests scenarios, interpreting the outputs of the application. But my application is not compiled as a console application : it is compiled as a window application. This causes no trouble to the ruby script that can, thanks to the IO.popen command, retrieve data output to stdout, even if the application is not compiled in console mode.

But, when executed with your coverage tool, if application is not compiled in console mode, it does not work anymore.

I did not analyse in detail why it does not work because, it's not a problem for me to recompile this application in console mode for the unit tests.


Marked as answer by OpenCppCoverage on 3/6/2016 at 3:29 AM
Jan 4, 2017 at 10:08 AM
I had the same issue with a Qt application. Running it alone provided output on stdout without problem, but I could not see it when running under OpenCppCoverage.

But adding:
CONFIG += console
to the .pro file and recompile made it work. So problem solved, but a bit confusing.