title: Continuous integration: ensure new commits are covered with tests
body: <p>I'm working on a project that has a lot of legacy code that is not covered with tests. </p>
  
  <p>Is there any way that I could set up the integration server to check that all new commits have a minimum amount of tests (say, coverage is >70%)?</p>
  
  <p>Essentially, I see two options:</p>
  
  <ol>
  <li>Somehow set up the CI server to fail the build when the committed changes are not covered with unit tests. This will ensure that every piece of new code will have tests and that tests for the legacy code will increase with each change.</li>
  <li>Set a coverage threshold for the whole project and fail the build if the coverage percentage decreases after a commit. The problem with this is that if I delete a class containing 100 instructions and add a new class with 50 instructions the coverage percentage will go up without me writing any tests.</li>
  </ol>
  
  <p>I like option 1 more because it forces changes in legacy code to be unit tested. This should increase the overall test coverage.</p>
  
  <p>Right now we're using Jenkins as our CI server and JaCoCo for test coverage. Maven is used for building the project and SVN is our main source control.</p>