Open ysh329 opened 4 years ago
以C/C++的覆盖率工具lcov为例:
C/C++
lcov
gcov随着gcc发布, lcov随ltp发布 http://ltp.sourceforge.net/coverage/lcov.php
编译选项 CFLAGS :-fprofile-arcs –f test-coverage or –coverage –O0
-fprofile-arcs –f test-coverage or –coverage –O0
链接选项 LDFLAGS:-lgcov or –coverage
-lgcov or –coverage
需要关闭优化选项,否则会覆盖率工具的测试
对于C/C++,第三方库(已经成为.o文件),无法编译插桩
$ pip install coverage # 下面是三个工具,都是基于coverage $ pytest --cache-clear \ --cov-report=xml \ --cov-report=html \ --html=junit.html \ --junitxml=./junit.xml \ -v \ --cov-branch \ -s \ --cov=./ $ nosetests -v \ --with-coverage \ --cover-branches \ --cover-xml \ --cover-html \ --with-html \ --with-xunit \ --xunit-file=junit.xml \ –s $ nose2 --verbose \ --with-coverage \ --coverage-report html \ --coverage-report xml \ --junit-xml
覆盖率工具原理
以
C/C++
的覆盖率工具lcov
为例:C/C++打桩原理介绍
Python覆盖率报表解析
覆盖率标准
提升覆盖率:案例
C/C++
gcov随着gcc发布, lcov随ltp发布 http://ltp.sourceforge.net/coverage/lcov.php
编译选项 CFLAGS :
-fprofile-arcs –f test-coverage or –coverage –O0
链接选项 LDFLAGS:
-lgcov or –coverage
需要关闭优化选项,否则会覆盖率工具的测试
对于C/C++,第三方库(已经成为.o文件),无法编译插桩
Python