wcc526的专栏

博客已搬至http://www.wengchichi.com

github 之 如何在项目中加入coverage

前言

我们常见github中有代码覆盖率的展示


a. 覆盖率数据只能代表你测试过哪些代码,不能代表你是否测试好这些代码。(比如除零Bug)
b. 不要过于相信覆盖率数据。
c. 不要只拿语句覆盖率(行覆盖率)来考核你的测试人员。
d. 路径覆盖率 > 判定覆盖 > 语句覆盖
e. 测试人员不能盲目追求代码覆盖率,而应该想办法设计更多更好的案例,哪怕对覆盖率无影响。

安装方法

安装见https://github.com/coagulant/coveralls-python

1.First, log in via Github and add your repo on Coveralls website.

2.Add pip install coveralls to install section of .travis.yml

3.Make sure you run your tests with coverage during the build in script part. Example:

# --source specifies what packages to cover, you probably want to use that option
script:
  coverage run --source=yourpackagename setup.py test

Note, that example command will gather coverage for specified package. If you wish to customize what's included in your reports, consult coverage docs.

4.Execute run coveralls in after_success section:

after_success:
  coveralls

5. travis.yml文件
language: python
python:
  - 2.7
  - 3.3
install:
  - pip install -r requirements.txt
  - pip install coveralls
script:
  coverage run --source=moscowdjango,meetup manage.py test
after_success:
  coveralls


可以参照的例子

https://github.com/WoLpH/python-formatter





阅读更多
文章标签: github
个人分类: github
想对作者说点什么? 我来说一句

Test Coverage

Test Coverage

martinmoy martinmoy

2011-03-29 08:40:00

阅读数:67

目中加入redis

redis

qq_20741133 qq_20741133

2017-06-27 10:36:01

阅读数:568

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭