How to get travis to fail if tests do not have enough coverage for python

旧时模样 提交于 2019-12-21 12:01:45

问题


I it possible to have travis fail if my test don't have enough coverage, say < 90% for example.

Normally I run my tests with the following travis config entry.

script:
 - coverage run --source="mytestmodule" setup.py test

回答1:


According to this link, if you add the --fail-under switch to the coverage report command, it will exit with a non-zero exit code (which travis will see as a failure) if the code coverage is below the given percentage.

That would make the script section of your .travis.yml file look like:

script
 - coverage run --source="mytestmodule" setup.py test
 - coverage report --fail-under=80

Of course you could replace 80 with whatever percentage you'd like.



来源:https://stackoverflow.com/questions/33965755/how-to-get-travis-to-fail-if-tests-do-not-have-enough-coverage-for-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!