gpt4 book ai didi

jacoco-maven-plugin - Jacoco 报告丢失

转载 作者:行者123 更新时间:2023-12-04 01:38:43 81 4
gpt4 key购买 nike

我正尝试在我的 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] 由于缺少执行数据文件而跳过 JaCoCo 执行。

我忘记了什么?

最佳答案

我的项目是用 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 的评论,我找到了 awnser 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>

关于jacoco-maven-plugin - Jacoco 报告丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58466551/

81 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com