【问题标题】:Jacoco Report missingJacoco 报告丢失
【发布时间】:2020-02-16 09:03:38
【问题描述】:

我正在尝试在我的project 上创建一个 jacoco 报告。该项目是 java 12 版本,jacoco-maven-plugin 是 0.8.5 版本。

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.5</version>
                <executions>
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

我启动了一个 mvn clean 站点

mvn clean install site

我得到:

[INFO] --- jacoco-maven-plugin:0.8.5:prepare-agent (pre-unit-test) @ bowling-game ---
[INFO] argLine set to -javaagent:/home/baptiste/.m2/repository/org/jacoco/org.jacoco.agent/0.8.5/org.jacoco.agent-0.8.5-runtime.jar=destfile=/home/baptiste/IdeaProjects/Bowling-Game/target/jacoco.exec

...
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ bowling-game ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.keywer.kata.bowling.game.frame.state.FrameStateTest
[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.064 s - in com.keywer.kata.bowling.game.frame.state.FrameStateTest
[INFO] Running com.keywer.kata.bowling.game.BowlingGameTest
[INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 s - in com.keywer.kata.bowling.game.BowlingGameTest
...
[INFO] --- jacoco-maven-plugin:0.8.5:report (post-unit-test) @ bowling-game ---
[INFO] Skipping JaCoCo execution due to missing execution data file.

我正在寻找报告,但实际上它没有被创建,原因如下:
[INFO] Skipping JaCoCo execution due to missing execution data file。

我忘记了什么?

【问题讨论】:

    标签: jacoco-maven-plugin


    【解决方案1】:

    我的项目是用 java 12 版本编写的,我启用了这样的预览功能。

    <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.1</version>
        <configuration>
          <argLine>--enable-preview</argLine> <=== This line
        </configuration>
    </plugin>
    

    问题是 maven 无法生成 jacoco.exec。

    感谢@Jacek Laskowski 的评论https://stackoverflow.com/a/23605812/8591625,我找到了遮阳篷

    我只是替换为

    <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.1</version>
        <configuration>
           <argLine>${argLine} --enable-preview</argLine> <=== Here I adding ${argLine} in order to not override argument
        </configuration>
    </plugin>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-18
      • 1970-01-01
      • 1970-01-01
      • 2018-07-22
      • 2016-11-25
      相关资源
      最近更新 更多