Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 607
Fabian Barkhau Avatar asked Nov 27 '15 22:11

Fabian Barkhau


1 Answers

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.

like image 86
Chathan Driehuys Avatar answered Nov 15 '22 12:11

Chathan Driehuys