Ask Your Question
0

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

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

thinwybk gravatar image

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

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...

<launch>
  <node name="talker" pkg="rospy" type="talker.py" />

  <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" />
</launch>

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

<launch>
  <node name="talker" pkg="rospy" type="talker.py" />

  <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" />
</launch>

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/case.py", line 329, in run
    testMethod()
  File "/home/florian/ws_catkin/src/ros_comm/tools/rostest/src/rostest/runner.py", line 121, in fn
    self.assert_(not failed, "Test Fixture Nodes %s failed to launch"%failed)
  File "/usr/lib/python2.7/unittest/case.py", 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/case.py", line 331, in run
    testMethod()
  File "/opt/ros/indigo/share/rostest/nodes/hztest/hztest", line 89, in test_hz
    self.fail('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/case.py", line 412, in fail
    raise self.failureException(msg)
--------------------------------------------------------------------------------
-------------------------------------------------------------
SUMMARY:
 * RESULT: FAIL
 * 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

Comments

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

ahendrix gravatar imageahendrix ( 2017-10-07 12:58:49 -0600 )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 imagethinwybk ( 2017-10-09 04:48:20 -0600 )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.

Thanks.

gvdhoorn gravatar imagegvdhoorn ( 2017-10-09 05:42:44 -0600 )edit

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

thinwybk gravatar imagethinwybk ( 2017-10-09 05:55:57 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

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

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

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

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

Seen: 815 times

Last updated: Oct 11 '17