Fail tests when coverage not enough

Jens Rantil avatarJens Rantil created an issue

Seems pretty empty here - I hope I am filing my issue in the right place.

I have a project where I aim to not loose coverage for my tests. Therefor I would love to have my test suite failing if coverage either above certain threshold (percentagewise or linewise). This would a really neat feature. Is this doable?

Comments (4)

  1. memedough

    This nose plugin controls coverage to produce a coverage report.

    Use a continuous integration server (e.g. Jenkins) to check the coverage report and fail if not good enough.

    If you still think that nose itself should fail the tests (instead of Jenkins) then please describe how you think it should work. I may accept a patch if it fits well with nose and the nose-cov plugin. Though this seems like the job of Jenkins rather than nose.

  2. Dmitry Medvinsky

    The built-in coverage plugin for nose has an option --cover-min-percentage. If you, say, run nosetests --with-cover --cover-min-percentage=95 and your coverage is below 95%, nosetests will exit with code 1 which makes it very easy to mark build as failed in Jenkins.

    So, maybe such an option might be available in nose-cov, too.

  3. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.