title: Cobertura : how to cover spring-data @Repository interfaces
body: <p>Regarding following information :</p>
  
  <p><a href="https://stackoverflow.com/a/14601831/704246">https://stackoverflow.com/a/14601831/704246</a></p>
  
  <blockquote>
    <p>Cobertura does not instrument interfaces</p>
  </blockquote>
  
  <p>I'd like to know how to add spring-data interfaces to coverage results, since <code>@Repository</code> implementation classes are only declared and instantiated by Spring at runtime.</p>
  
  <p>Consider following interface :</p>
  
  <pre><code>// src/main/java/my/package/MyObjectRepository.java
  
  @Repository
  public interface MyObjectRepository  {
      MyObject findMyObjectByCodeAndName(String code, String name);
  }
  </code></pre>
  
  <p>and following test :</p>
  
  <pre><code>// src/test/java/my/package/MyObjectRepositoryTest.java
  
  // @RunWith(SpringJUnit4ClassRunner.class) + Spring configuration
  public class MyObjectRepositoryTest {
  
      @Autowired
      private MyObjectRepository myObjectRepository;
  
      @Test
      public void myTest() {
          myObjectRepository.findMyObjectByCodeAndName("foo","bar");  
      }
  }
  </code></pre>
  
  <p>I don't mind switching to Jacoco, but I've read that it doesn't instrument interfaces either.</p>
  
  <p>How can following cases be covered ? The same issue/question occurs regarding Mybatis Mapper, which are declared as interfaces but no concrete Java class declaration implementing them is written by the developer but by the framework at runtime.</p>
  
  <p>I've opened a <a href="http://github.com/cobertura/cobertura/issues/279" rel="nofollow noreferrer">ticket</a> but I'm still waiting for an answer.</p>