1. 安装gtest
sudo apt-get install libgtest-dev
2.修改CMakeLists.txt
find_package(GTest REQUIRED)
uncommend catkin_add_gtest
3. 添加覆盖率统计编译选项
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGES} -fprofile-arcs -ftest-coverage")
4.运行测试用例
http://docs.ros.org/jade/api/catkin/html/howto/format1/run_tests.html
catkin_make run_tests_packagename_gtest_mytestexename
时间: 2024-10-12 13:25:06