Tutorial :How to fail the build when there is new uncovered code?



Question:

Do any code coverage tools for Java allow you to cause the build to fail when new uncovered code gets introduced? I don't want to fail the build based on an arbitrary cutoff like 80% because in a large codebase, the actual coverage percentage rarely fluctuates. Also if coverage falls by 0.1% it's hard to tell which are the new uncovered lines.

EDIT

I'm convinced not to fail the build. The other part of the question still stands. How can I find only the uncovered code that was recently checked in?


Solution:1

If you are using a continuous integration server such as Hudson, you can delegate this requirement to a new job which is dependent on the build (which runs during each commit, say).

Create a script which runs your code coverage profile, and fails based on a metric. Include a wget or cURL retrieval of the previous build's code coverage percent, parsed out, if you want to use an automatic metric.


Solution:2

Hudson cobertura plugin let you to rise build warnings and the native "changes" view will tell you what is the new code that do not have coverage


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »