ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

How can I use test nodes in rostest which are not part of rostest itself?

asked 2017-10-07 09:19:02 -0500

thinwybk gravatar image

updated 2017-10-09 05:41:48 -0500

gvdhoorn gravatar image

I want to test a ROS node with rostest but with a test node which is not included in rostest itself. Means instead of using the hztest test node like in this rostest test...

  <node name="talker" pkg="rospy" type="" />

  <param name="hztest1/topic" value="chatter" />  
  <param name="hztest1/hz" value="10.0" />
  <param name="hztest1/hzerror" value="0.5" />
  <param name="hztest1/test_duration" value="5.0" />    
  <param name="hztest1/wait_time" value="21.0" />    
  <test test-name="hztest_test" pkg="rostest" type="hztest" name="hztest1" />

... I would like to use my own test node owntest from my own ROS Python package ownpackage instead:

  <node name="talker" pkg="rospy" type="" />

  <param name="owntest1/topic" value="chatter" />  
  <param name="owntest1/test_duration" value="5.0" />    
  <test test-name="owntest_test" pkg="ownpackage" type="owntest" name="owntest1" />

I built and installed ownpackage with catkin_make --pkg ownpackage, cd /build/ownpackage and make install. However if I run the test I get an error because rostest does not know about the existence of owntest:

FAILURE: Test Fixture Nodes ['owntest'] failed to launch
  File "/usr/lib/python2.7/unittest/", line 329, in run
  File "/home/florian/ws_catkin/src/ros_comm/tools/rostest/src/rostest/", line 121, in fn
    self.assert_(not failed, "Test Fixture Nodes %s failed to launch"%failed)
  File "/usr/lib/python2.7/unittest/", line 422, in assertTrue
    raise self.failureException(msg)

How can I let rostest know about the existence of the owntest node from ownpackage that rostest can use it in a test?

Or alternativelly: What is the best approach/development procedure when I would place owntest into ros_comm/rostest/nodes instead of into ownpackage?

Edit: If I start the roscore and try to run a rostest test node with rosrun rostest hztest I got the following output:

[ROSUNIT] Outputting test results to /home/kromer/.ros/test_results/rostest/rosunit-hztest.xml
test_hz ... FAILURE!
FAILURE: hztest not initialized properly. Parameter ['~hz'] not set. debug[/hztest] debug[/hztest/hz]
  File "/usr/lib/python2.7/unittest/", line 331, in run
  File "/opt/ros/indigo/share/rostest/nodes/hztest/hztest", line 89, in test_hz'hztest not initialized properly. Parameter [%s] not set. debug[%s] debug[%s]'%(str(e), rospy.get_caller_id(), rospy.resolve_name(e.args[0])))
  File "/usr/lib/python2.7/unittest/", line 412, in fail
    raise self.failureException(msg)
 * TESTS: 1
 * ERRORS: 0 []
 * FAILURES: 1 [test_hz]

I would expect the same for my package. I diff the files of my package and rostest to figure out what I missed...

edit retag flag offensive close merge delete


This should work if you can run owntest with rosrun. Try rosrun ownpackage owntest

ahendrix gravatar image ahendrix  ( 2017-10-07 12:58:49 -0500 )edit

If I run rosrun rosfake faketopicpublisherint32.test I get the error [rospack] Error: package 'rosfake' not found not found`. Seems like I missed or messed up something in the package definition of the package.

thinwybk gravatar image thinwybk  ( 2017-10-09 04:48:20 -0500 )edit

@thinwybk: please only use answers to answer your own question. For everything else, use comments or edit your original question text.

I've already merged your update into your OP, but please keep it in mind for next time.


gvdhoorn gravatar image gvdhoorn  ( 2017-10-09 05:42:44 -0500 )edit

@gvdhoorn Thanks for the hint. I will consider that in the future.

thinwybk gravatar image thinwybk  ( 2017-10-09 05:55:57 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-10-11 11:14:56 -0500

thinwybk gravatar image

Sorry for that stupid question. I just forgot to make owntest executable with chmod +x owntest.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-10-07 09:19:02 -0500

Seen: 1,485 times

Last updated: Oct 11 '17