lcov基本使用方法

// 1 依赖
apt install lcov

// 2 以gtest sample10为例进行lcov测试
// 编译后会出现*.gcno文件
g++ –fprofile-arcs –ftest-coverage -o sample10 sample10_unittest.cpp -L xxx/gtest/lib -lgtest -lpthread

// 3 运行后会出现*.gcda文件
./sample10

// 4 "./"要对应*.gcda文件的目录
lcov -d ./ -t 'test' -o 'test.info' -b . -c

// 5 根据test.info生成覆盖率报告
genhtml -o result test.info

在当前目录下生成gtest统计报告,统计总测试用例和通过测试用例数:

bin --gtest_output=xml:./

参考资料:

C++ 测试覆盖率统计轻量方案-gtest+lcov_lvley的博客-CSDN博客_gtest覆盖率

Guess you like

Origin blog.csdn.net/u012906122/article/details/120022741