Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikeferguson/code_coverage
ROS package to run coverage testing
https://github.com/mikeferguson/code_coverage
Last synced: 3 months ago
JSON representation
ROS package to run coverage testing
- Host: GitHub
- URL: https://github.com/mikeferguson/code_coverage
- Owner: mikeferguson
- Created: 2018-06-13T01:26:14.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-08-29T21:16:09.000Z (about 1 year ago)
- Last Synced: 2024-05-09T07:31:45.650Z (6 months ago)
- Language: CMake
- Size: 43.9 KB
- Stars: 38
- Watchers: 7
- Forks: 25
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.rst
Awesome Lists containing this project
- awesome-ros-tools - code_coverage - ROS package to run coverage testing. [Introduction.](http://www.robotandchisel.com/2020/04/07/code-coverage-for-ros/) ![code_coverage](https://img.shields.io/github/stars/mikeferguson/code_coverage.svg?style=flat&label=Star&maxAge=86400) (Code Testing / Extracting data)
- awesome-robotic-tooling - code_coverage - ROS package to run coverage testing. (Development Environment / Unit and Integration Test)
README
# code_coverage
ROS package to run coverage testing
## Examples
* The [robot_calibration](https://github.com/mikeferguson/robot_calibration) package uses this to generate coverage for C++ code using Travis-CI and Codecov.io
## 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 the following. **NOTE** the order of test targets and coverage macros:
```cmake
if(CATKIN_ENABLE_TESTING AND ENABLE_COVERAGE_TESTING)
find_package(code_coverage REQUIRED)
# Add compiler flags for coverage instrumentation before defining any targets
APPEND_COVERAGE_COMPILER_FLAGS()
endif()
# Add your targets here
if (CATKIN_ENABLE_TESTING)
# Add your tests here
# Create a target ${PROJECT_NAME}_coverage_report
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_report
DEPENDENCIES _run_tests_${PROJECT_NAME}
)
endif()
endif()
```
* **Note**: The variable `COVERAGE_EXCLUDES` must have some content!
* 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
catkin_make -DENABLE_COVERAGE_TESTING=ON -DCMAKE_BUILD_TYPE=Debug PACKAGE_NAME_coverage_report
```
- 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_report
```* The output will print where the coverage report is located
## Python rostest Support
While the C++ interface and Python-based unit tests require no
modification to get coverage information, Python-based nodes
run from rostest launch files need a bit of additional
instrumentation turned on:```xml
```
In the CMakeLists, you will need to pass this argument:
```cmake
add_rostest(example_rostest.test ARGS coverage:=ENABLE_COVERAGE_TESTING)
```