I have a TeamCity build that captures code coverage for unit tests. I have also defined an environment variable for the minimum code coverage for the build to succeed, which works fine but I don't like to maintain this threshold manually. The question I have is whether there is a way (outside of publishing code coverage statistics somewhere outside of TeamCity and then reading the results from the last successful build) to automatically adjust the threshold as code coverage improves to ensure that it's a steady improvement without allowing backsliding :)?
For example, suppose the current code coverage is 20% (a legacy application) and as new unit tests are written, code coverage improves to 25%. Then, someone checks in new code without unit tests and code coverage drops to 24%. I would want TeamCity to fail the build because code coverage dropped from 25% to 24%.
This is an old question but I wanted to mention that this is now possible in newer versions of TeamCity through the "Failure Conditions" feature. Failure conditions can use constants as well as compare to previously generated metrics. In this case, a failure condition would look like this: