简体   繁体   中英

java code coverage with jacoco

I have a next project structure

src/main/java/com/Example.java
src/main/java/com/ExampleMapper.java

i need to get code coverage for ExampleMapper without Example class. I write in pom.xml

  <plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.7.1.201405082137</version>
    <executions>
      <execution>
        <goals>
          <goal>prepare-agent</goal>
        </goals>
      </execution>
      <execution>
        <id>report</id>
        <phase>prepare-package</phase>
        <goals>
          <goal>report</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <includes> 
        <include>com/example/**/*Mapper.class</include>
      </includes>
    </configuration>
  </plugin>

But, i got 0% as coverage output.

Hot to fix this?

You need to change it to this:

<include>com/example/*Mapper*</include>

Then, Jacoco works correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM