3

That's basically the idea. I own a project and I want to break any new build on TeamCity based on a code coverage percentage. As simply as: this percentage can never go down. This way I ensure that new commits are covered.

Rober
  • 726
  • 8
  • 27
  • The term for a process that only allows a metric to go in one direction is usually called a *ratchet* (after the mechanical tool). – RJHunter Jun 23 '16 at 12:39

1 Answers1

3

TeamCity provides this out of the box. Simply go to the configuration for the project, and click 'Failure Conditions'. This gives you a place whwre you can add a failure condition on a metric change. One of the available metric changes is 'Percentage of line coverage'. You can set it so that the build fails if this is less the 0 difference from the last build.

enter image description here

Beware adding this though, especially if you have projects where the code coverage is not 100% already, as a refactoring which reduces the number of lines in the project and all of those lines happen to be covered by tests will result on the overall coverage going down, and a failing build despite not adding any new functionality.

Sam Holder
  • 32,535
  • 13
  • 101
  • 181