1

As the question says, I am having trouble seeing std::out statements in the eclipse console when using the "c/c++ unit" run configuration with boost.test.

Here is a simple example describing the issue.

quickEclipse_stdout.cpp:

#include <iostream>
int main(int argc, char* argv[])
{
    std::cout << "I see this in the eclipse console!\n";
    std::cout << "I also see this in the terminal!\n";
    return(0);
}

quickEclipse_stdout_test.cpp:

#include <iostream>
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(quickTest_stdout)

BOOST_AUTO_TEST_CASE(bla)
{
   std::cout << "I cannot see this in the eclipse console" << std::endl;
   std::cout << "but I can see it when run outside eclipse in terminal" << std::endl;

    BOOST_CHECK_MESSAGE(true, "of course I see this in eclipse c/c++ test log");
}

BOOST_AUTO_TEST_SUITE_END()

I used cmake to generate project files for eclipse.

CMakeLists.txt:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(quickTest CXX)

FIND_PACKAGE(Boost COMPONENTS program_options filesystem regex unit_test_framework)
IF (Boost_FOUND)
    MESSAGE("Boost found!!!")
    INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
    LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
    ADD_DEFINITIONS( "-DHAS_BOOST" )
ENDIF()

#main output to console works
ADD_EXECUTABLE(quickEclipse_stdout, quickEclipse_stdout.cpp)

#boost.test output to console doesnt work
ADD_EXECUTABLE(quickEclipse_stdout_test UTDriver.cpp quickEclipse_stdout_test.cpp) 
TARGET_LINK_LIBRARIES(quickEclipse_stdout_test ${Boost_LIBRARIES})

UTDriver.cpp:

#define BOOST_TEST_MODULE myQuickEclipseUT
#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>

To generate the eclipse project I run the following command:

cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_ECLIPSE_VERSION=4.3 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER_ARG1=-std=c++11 ~/mySrcDir
  1. I open the project in eclipse and enter c++ perspective
  2. I then build the executables by double-clicking on make targets (quickEclipse_stdout, quickEclipse_stdout_test)
  3. I goto run configurations and create "c/c++ application" for quickEclipse_stdout.
  4. I goto run configurations and create "c/c++ unit" for quickEclipse-stdout_test and select boost as the test runner.
  5. I run quickEclipse_stdout and see the output in eclipse console.
  6. I run quickEclipse_stdout_test and the eclipse console is empty. I see the message in the c/c++ unit messages tab.
  7. I can see the std::out on both if I run the executables in a terminal outside eclipse.

How can I get the std::out to show in the eclipse console when running the quickEclipse_stdout_test?

I am on Linux CentOS 6.5.

Eclipse Standard/SDK Version: Kepler Service Release 1 Build id: 20130919-0819

Eclipse C/C++ Development Tools Version: 8.2.1.201309180223

PopcornKing
  • 1,370
  • 3
  • 18
  • 23

2 Answers2

0

Im sure based on your description its redirecting stdout to its own window for testing purposes

Steve
  • 502
  • 3
  • 12
0

I am exactly in your situation and I think it is a missing feature of the C/C++ unit test plugin in Eclipse.

The plugin requires the whole test output in xml format (--output_format=XML) which puts the stdout messages in the node of the xml output. The output will be directly parsed by the plugin and the information is organized in the according view. The plugin misses the option to show the stdout messages. I could simply have a further icon beside error, warning, information to show the stdout messages.

I have opened an issue for this on github: https://github.com/xgsa/cdt-tests-runner/issues/14 but the project it not actively maintained the last years...

nils
  • 61
  • 4
  • I am pretty sure this is an answer. An answer is not always a solution, but it describes the technical details and how a solution could look like (+what has been done to get to this solution). Furthermore I do not have another question, I simply described technical background of the question and that the required output format XML causes the issue. – nils May 09 '16 at 07:35