Skip to content
ROS package to run coverage testing
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmake
CHANGELOG.rst
CMakeLists.txt
README.md
package.xml

README.md

code_coverage

ROS package to run coverage testing

Usage

To use this with your ROS package:

  • Add code_coverage as a test depend in your package.xml
  • Update your CMakeLists.txt, in the testing section add:
if (CATKIN_ENABLE_TESTING)
  find_package(code_coverage REQUIRED)

  if(ENABLE_COVERAGE_TESTING)
    include(CodeCoverage)
    APPEND_COVERAGE_COMPILER_FLAGS()
  endif()

  # Add your tests here

  if(ENABLE_COVERAGE_TESTING)
    set(COVERAGE_EXCLUDES "*/${PROJECT_NAME}/test*" "*/${PROJECT_NAME}/other_dir_i_dont_care_about*")
    add_code_coverage(
      NAME ${PROJECT_NAME}_coverage
      DEPENDS tests
    )
  endif()
endif()
  • Now you can build and run the tests (you need a debug build to get reasonable coverage numbers):

    • if using CATKIN_MAKE:
        catkin_make -DENABLE_COVERAGE_TESTING=ON -DCMAKE_BUILD_TYPE=Debug package_name_coverage
    
    • if using CATKIN_TOOLS:
      catkin config --cmake-args -DENABLE_COVERAGE_TESTING=ON -DCMAKE_BUILD_TYPE=Debug
      catkin build
      catkin build PACKAGE_NAME -v --no-deps --catkin-make-args PACKAGE_NAME_coverage 
    
  • The output will print where the coverage report is located

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.