Ask Your Question

Process dies for with "option --gtest_output not recognized" error

asked 2018-07-06 00:57:52 -0500

130s gravatar image

Running test cases in a subclass of unittest.TestCase via rostest fails with the following error.

rostest pkg_a webbridge.test
... logging to /root/.ros/log/rostest-7748a8fc08fa-7285.log
[ROSUNIT] Outputting test results to /root/.ros/test_results/pkg_a/rostest-test_webbridge.xml
[Testcase: testmodule_a] ... FAILURE!
FAILURE: test [module_a] did not generate test results
  File "/usr/lib/python2.7/unittest/", line 329, in run
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rostest/", line 164, in fn
    self.assert_(os.path.isfile(test_file), "test [%s] did not generate test results"%test_name)
  File "/usr/lib/python2.7/unittest/", line 422, in assertTrue
    raise self.failureException(msg)



 * TESTS: 0
 * ERRORS: 0

ERROR: The following tests failed to run:
 * testmodule_a

rostest log file is in /root/.ros/log/rostest-7748a8fc08fa-7285.log

Only obviously suspicious thing in the log is the following:

[roslaunch][INFO] 2018-07-06 05:07:35,927: ... successfully launched [module_a-2]
[rostest][ERROR] 2018-07-06 05:07:36,282: [module_a-2] process has died [pid 7306, exit code 2, cmd /root/catkin_ws/src/prj_tools/pkg_a/test/src/ --gtest_output=xml:/root/.ros/test_results/pkg_a/rosunit-module_a.xml __name:=module_a __log:=/root/.ros/log/7e86be42-80da-11e8-b6ce-0242ac110003/module_a-2.log].
log file: /root/.ros/log/7e86be42-80da-11e8-b6ce-0242ac110003/module_a-2*.log

Digging further:

$ more /root/.ros/log/7e86be42-80da-11e8-b6ce-0242ac110003/module_a-2*.log

option --gtest_output not recognized
Usage: [options] [test] [...]

  -h, --help       Show this message
  -v, --verbose    Verbose output
  -q, --quiet      Minimal output
  -f, --failfast   Stop on first failure
  -c, --catch      Catch control-C and display results
  -b, --buffer     Buffer stdout and stderr during test runs

Examples:                               - run default set of tests MyTestSuite                   - run suite 'MyTestSuite' MyTestCase.testSomething      - run MyTestCase.testSomething MyTestCase                    - run all 'test*' test methods
                                               in MyTestCase

Simplified test case for public view:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest

import rospy
from sensor_msgs.msg import Image
from std_srvs.srv import Trigger

from pkg_a.module_a import ClassA

class TestClassA(unittest.TestCase):

    def setUp(self):
        self._webbridge = ClassA()

    def cb_img(self, data):

    def test_a(self):
    _srv_name = "srv_a"
            _srv_proxy = rospy.ServiceProxy(_srv_name, Trigger)
            _response = _srv_proxy()
        except rospy.ServiceException, e:
            raise e

        # Assertion happens in the callback.
        rospy.Subscriber(_topic_name, Image, self.cb_img)

if __name__ == '__main__':
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-07-06 01:01:05 -0500

130s gravatar image

updated 2018-07-06 01:28:59 -0500

Self-answering as I figured it out. Test case file needs to be started by rostest.rosrun like the following code as mentioned in unittest#unittest_code wiki page.

if __name__ == '__main__':
    import rostest
    rostest.rosrun(PKG, 'test_a_node', TestClassA)

Took me a few hours as no direct error output wasn't printed anywhere AFAICT...

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


Asked: 2018-07-06 00:57:52 -0500

Seen: 319 times

Last updated: Jul 06 '18