yuenshome / yuenshome.github.io

https://yuenshome.github.io
MIT License
81 stars 15 forks source link

代码覆盖率工具 #75

Open ysh329 opened 4 years ago

ysh329 commented 4 years ago

覆盖率工具原理

C/C++的覆盖率工具lcov为例:

image

C/C++打桩原理介绍

image

Python覆盖率报表解析

image

覆盖率标准

image

提升覆盖率:案例

image

C/C++

Python

$ 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