Jacoco doesn't produce coverage reports

前端 未结 1 1559
情深已故
情深已故 2020-12-22 05:03

I \'m using maven-sure fire plugin to execute tests and Jacoco plugin to generate the coverage reports. Jacoco does\'t provide coverage reports and instead fails with the d

相关标签:
1条回答
  • 2020-12-22 06:02

    Quoting http://www.jacoco.org/jacoco/trunk/doc/prepare-agent-mojo.html :

    If your project already defines VM arguments for test execution, be sure that they will include property defined by JaCoCo.

    One of the ways to do this in case of maven-surefire-plugin - is to use syntax for late property evaluation:

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <configuration>
        <argLine>@{argLine} -your -extra -arguments</argLine>
      </configuration>
    </plugin>
    

    Another way is to define "argLine" as a Maven property rather than as part of the configuration of maven-surefire-plugin:

    <properties>
      <argLine>-your -extra -arguments</argLine>
    </properties>
    ...
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <configuration>
        <!-- no argLine here -->
      </configuration>
    </plugin>
    

    so either define

    <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea
                        -Dfile.encoding=UTF-8</argLine>
    

    as property:

    <build>
      <properties>
        <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea
                        -Dfile.encoding=UTF-8</argLine>
      </properties>
    ...
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.10</version>
        <configuration>
          <!-- no argLine here -->
    

    or add @{argLine} to it:

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.10</version>
      <configuration>
        <argLine>@{argLine} -Xms256m -Xmx512m -XX:MaxPermSize=128m -ea
                        -Dfile.encoding=UTF-8</argLine>
    
    0 讨论(0)
提交回复
热议问题