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

Measuring code coverage in ROS

asked 2019-04-29 05:47:43 -0500

updated 2019-04-29 06:34:37 -0500


I am looking for a solution to measure code coverage in ROS. For example, in the ROS turtlesim package, I would like to measure how many functions / branches / program-blocks the tutorial program draw_square.cpp reaches during its execution. Such coverage can be helpful, for example, in determining the thoroughness of a test program.

The ROS Continuous Integration page ( ) provides hints on some existing solutions of measuring coverage, but the page does not seem to give details.

For your information, I sometimes used GCOV for measuring C program coverage. I am looking for a solution that can deal with both C++ and Python programs in ROS.

Thank you.

edit retag flag offensive close merge delete


Perhaps mikeferguson/code_coverage can help here, or at least the C++ side. For Python I wouldn't know anything integrated/nice/ROS wrapped.

Edit: according to this the sr-build-tools project can provide code coverage for both C++ and Python. Haven't used it myself though.

gvdhoorn gravatar image gvdhoorn  ( 2019-04-29 06:05:15 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-04-29 07:22:00 -0500

Thomas D gravatar image

updated 2019-04-29 22:12:40 -0500

I have an example of doing code coverage using gcov for ROS C++ code at node_example. The tests are run as part of a Travis job and the results are uploaded to codecov, but you can also get the coverage results locally as well.

The relevant steps for doing code coverage of a ROS package can be found in the Travis configuration file at:

That package does not yet include tests for Python code.

edit flag offensive delete link more


Link not working.

Zhoulai Fu gravatar image Zhoulai Fu  ( 2020-10-16 06:10:11 -0500 )edit

I switched from Travis CI to Github Actions. The same approach is used.

Thomas D gravatar image Thomas D  ( 2020-10-16 09:49:53 -0500 )edit

Question Tools

1 follower


Asked: 2019-04-29 05:47:43 -0500

Seen: 1,451 times

Last updated: Apr 29 '19