When i run the unit test using rostest command it fails, when I run it using rosrun it always succeeds.
ROSRUN: ALWAYS SUCCEEDS
I am trying to create simple unit test that does nothing, it always returns the following :
SUMMARY:
* RESULT: SUCCESS
* TESTS: 0
* ERRORS: 0 []
* FAILURES: 0 []
Output of test results is
<?xml version="1.0" encoding="utf-8"?>
<testsuite errors="0" failures="0" name="unittest.suite.TestSuite" tests="0" time="0.000">
<system-out><![CDATA[]]></system-out>
<system-err><![CDATA[]]></system-err>
</testsuite>
I run it using rosrun package-name python-test-exec
this is my unit test file
#!/usr/bin/env python
from __future__ import print_function
PKG = 'sample_ros_py'
NAME = 'test_topic'
import sys
import unittest
from std_msgs.msg import String
import rospy
import rostest
import time
class test_topic(unittest.TestCase):
def __init__(self, *args):
self.success = False
def is_talker_up(self):
self.assertEquals(1,2)
def trial_2(self):
self.assertEquals(2,2)
if __name__ == '__main__':
rostest.rosrun(PKG, NAME, test_topic, sys.argv)
this is the cmake file :
if(CATKIN_ENABLE_TESTING)
find_package(rostest REQUIRED)
add_rostest(test/sample_ros_py.test)
endif()
Whatever I change in the python test file I always get the result.
ROSTEST : ALWAYS FAILING
Additionally I have a rostest file:
<?xml version="1.0" encoding="UTF-8"?>
<launch>
<node name="talker" pkg="sample_ros_py" type="talker" output="screen" />
<test test-name="test_topic_test" pkg="sample_ros_py" type="test_topic" name="test_topic"/>
</launch>
Which does not run at all!
I get :
[ROSUNIT] Outputting test results to /home/rama/.ros/test_results/sample_ros_py/rostest-test_sample_ros_py.xml
testtest_topic_test ... FAILURE!
FAILURE: Test node [sample_ros_py/test_topic] does not exist or is not executable
File "/usr/lib/python2.7/unittest/case.py", line 331, in run
testMethod()
File "/opt/ros/indigo/lib/python2.7/dist-packages/rostest/runner.py", line 93, in fn
self.fail(message)
File "/usr/lib/python2.7/unittest/case.py", line 412, in fail
raise self.failureException(msg)
--------------------------------------------------------------------------------
[ROSTEST]-----------------------------------------------------------------------
[testtest_topic_test][failed]
SUMMARY
* RESULT: FAIL
* TESTS: 0
* ERRORS: 0
* FAILURES: 1
ERROR: The following tests failed to run:
* testtest_topic_test
Why does is succeed in one and fail in the other?
this is the log file content :
[rostest][INFO] 2017-11-15 12:16:07,447: rostest starting with options {'text_mode': False, 'pkg_dir': None, 'results_base_dir': None, 'package': None, 'clear': None, 'reuse_master': None, 'results_filename': None}, args ['/home/rama/catkin_ws/src/sample_ros_py/test/sample_ros_py.test']
[roslaunch][INFO] 2017-11-15 12:16:07,466: loading roscore config file /opt/ros/indigo/etc/ros/roscore.xml
[roslaunch][INFO] 2017-11-15 12:16:07,565: Added core node of type [rosout/rosout] in namespace [/]
[roslaunch.config][INFO] 2017-11-15 12:16:07,566: loading config file /home/catkin_ws/src/sample_ros_py/test/sample_ros_py.test
[roslaunch][INFO] 2017-11-15 12:16:07,568: Added node of type [sample_ros_py/talker] in namespace [/]
[roslaunch][INFO] 2017-11-15 12:16:07,568: ... selected machine [] for node of type [sample_ros_py/talker]
[roslaunch][INFO] 2017-11-15 12:16:07,568: ... selected machine [] for node of type [sample_ros_py/test_topic]
[rostest][INFO] 2017-11-15 12:16:07,597: setup[/home/rama/catkin_ws/src/sample_ros_py/test/sample_ros_py.test] run_id[607c2bd0-c9f6-11e7-b23e-7824af3a7c31] starting
[roslaunch.pmon][INFO] 2017-11-15 12:16:07,598: start_process_monitor: creating ProcessMonitor
[roslaunch.pmon][INFO] 2017-11-15 12:16:07,598: created process monitor <ProcessMonitor(ProcessMonitor-1, initial daemon)>
[roslaunch.pmon][INFO] 2017-11-15 12:16:07,598: start_process_monitor: ProcessMonitor started
[roslaunch.parent][INFO] 2017-11-15 12:16:07,598: starting parent XML-RPC server
[roslaunch.server][INFO] 2017-11-15 12:16:07,598: starting roslaunch XML-RPC server
[roslaunch.server][INFO] 2017-11-15 12:16:07,598: waiting for roslaunch XML-RPC server to initialize
[xmlrpc][INFO] 2017-11-15 12:16:07,598: XML-RPC server binding to 0.0.0.0:0
[xmlrpc][INFO] 2017-11-15 12:16:07,598: Started XML-RPC server [http://RR06:55327/]
[xmlrpc][INFO] 2017-11-15 12:16:07,598: xml rpc node: starting XML-RPC server
[rostest][INFO] 2017-11-15 12:16:07,609: started roslaunch server http://RR06:55327/
[roslaunch.parent][INFO] 2017-11-15 12:16:07,609: ... parent XML-RPC server started
[xmlrpc][INFO] 2017-11-15 12:16:07,610: XML-RPC server binding to 0.0.0.0:0
[xmlrpc][INFO] 2017-11-15 12:16:07,610: Started XML-RPC server [http://RR06:36971/]
[xmlrpc][INFO] 2017-11-15 12:16:07,610: xml rpc node: starting XML-RPC server
[rosmaster.master][INFO] 2017-11-15 12:16:07,610: Master initialized: port[0], uri[http://RR06:36971/]
[rostest][INFO] 2017-11-15 12:16:07,610: _addRostestParent [<rostest.rostest_parent.ROSTestLaunchParent object at 0x7f0b8107f4d0>]
[rostest][INFO] 2017-11-15 12:16:07,610: setup[/home/catkin_ws/src/sample_ros_py/test/sample_ros_py.test] run_id[607c2bd0-c9f6-11e7-b23e-7824af3a7c31] done
[rostest][INFO] 2017-11-15 12:16:07,611: tearDown[/home/rama/catkin_ws/src/sample_ros_py/test/sample_ros_py.test]
[roslaunch][INFO] 2017-11-15 12:16:07,611: runner.stop()
[rostest][INFO] 2017-11-15 12:16:07,611: shutting down processing monitor...
[roslaunch][INFO] 2017-11-15 12:16:07,611: shutting down processing monitor <ProcessMonitor(ProcessMonitor-1, started daemon 139687375009536)>
[roslaunch.pmon][INFO] 2017-11-15 12:16:07,611: ProcessMonitor.shutdown <ProcessMonitor(ProcessMonitor-1, started daemon 139687375009536)>
[roslaunch.pmon][INFO] 2017-11-15 12:16:07,698: ProcessMonitor._post_run <ProcessMonitor(ProcessMonitor-1, started daemon 139687375009536)>
[roslaunch.pmon][INFO] 2017-11-15 12:16:07,698: ProcessMonitor._post_run <ProcessMonitor(ProcessMonitor-1, started daemon 139687375009536)>: remaining procs are []
[roslaunch.pmon][INFO] 2017-11-15 12:16:07,702: ProcessMonitor exit: cleaning up data structures and signals
[roslaunch.pmon][INFO] 2017-11-15 12:16:07,702: ProcessMonitor exit: pmon has shutdown
[rostest][INFO] 2017-11-15 12:16:07,702: ... shutting down processing monitor complete
[roslaunch.pmon][INFO] 2017-11-15 12:16:07,703: ProcessMonitor.shutdown <ProcessMonitor(ProcessMonitor-1, stopped daemon 139687375009536)>
[rostest][INFO] 2017-11-15 12:16:07,703: rostest teardown /home/catkin_ws/src/sample_ros_py/test/sample_ros_py.test complete
[rostest][INFO] 2017-11-15 12:16:07,708: finally rostest parent tearDown [<rostest.rostest_parent.ROSTestLaunchParent object at 0x7f0b8107f4d0>]
[roslaunch][INFO] 2017-11-15 12:16:07,708: runner.stop()
[roslaunch][INFO] 2017-11-15 12:16:07,708: ... roslaunch runner has already been stopped
[rostest][INFO] 2017-11-15 12:16:07,709: calling pmon_shutdown
[rostest][INFO] 2017-11-15 12:16:07,709: ... done calling pmon_shutdown
[rospy.core][INFO] 2017-11-15 12:16:07,709: signal_shutdown [atexit]
Thank you
Originally posted by ramasri on ROS Answers with karma: 1 on 2017-11-15
Post score: 0