How can I use test nodes in rostest which are not part of rostest itself?
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...
This should work if you can run
owntest
withrosrun
. Tryrosrun ownpackage owntest
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: 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 Thanks for the hint. I will consider that in the future.