Ask Your Question

Show ROS_DEBUG ROS_INFO with catkin_make run_tests

asked 2018-02-14 01:32:04 -0500

agutenkunst gravatar image

updated 2018-02-14 01:32:33 -0500


I create a minimal example in order to illustrate my question. If i do the following small testcase:

class SimpleTest : public ::testing::Test
  virtual void SetUp(){return;}
  virtual void TearDown() {}

TEST_F(SimpleTest, OutputTest)
  ROS_DEBUG("Test Debug");
  ROS_INFO("Test Info");
  ROS_ERROR("Test Error");

int main(int argc, char **argv)
  ros::init(argc, argv, "simple_test");
  ros::NodeHandle node_handle;

  if( ros::console::set_logger_level(ROSCONSOLE_DEFAULT_NAME, ros::console::levels::Debug) )

  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();

if I run the test with

 catkin_make run_tests

it will only display the output from ROS_ERROR.

However if I run it via rostest and --text

rostest --text hello_world simple.test

it will show the output from ROS_DEBUG and ROS_INFO.

I would like to achieve the same output with catkin_make run_tests. So far I have trouble even understanding what is happening here and how the output can be different since essentially the same executable is called.

Any hints/recommendations?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-03-19 13:54:18 -0500

PaulBouchier gravatar image

I ran into a variant of this problem. In my case, the first test would print ROS_INFO messages, but subsequent tests wouldn't. I found it necessary to call ros::init and other ROS calls AFTER calling InitGoogleTests. I updated the ROS gtest wiki page at to show an example of initializing ROS after initializing gtest. I hope this helps.

edit flag offensive delete link more


I see the same issue w.r.t. only seeing the first ROS_INFO output when running gtest. @PaulBouchier, what did you do to get around this? I couldn't find anything on the wiki for gtest that shows a workaround.

mpark gravatar image mpark  ( 2018-04-16 11:57:43 -0500 )edit

I ran into the same problem. As suggested by You also need to add an additional ros::NodeHandle nh; between ros::init and RUN_ALL_TESTS(); so that the logging messages from all the test cases can be displayed.

dong gravatar image dong  ( 2020-01-03 06:17:04 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2018-02-14 01:32:04 -0500

Seen: 792 times

Last updated: Mar 19 '18