gpt4 book ai didi

java - 如何在 Maven 和 IntelliJ 之间共享三叶草覆盖率数据

转载 作者:行者123 更新时间:2023-11-30 09:09:18 25 4
gpt4 key购买 nike

我有一个多模块 项目。我正在使用 作为我的IDE。我用 配置了 Maven在构建时自动检测的插件。我怎样才能让 IntelliJ 识别这些更改并刷新其覆盖率数据。(注意: 必须单击“刷新覆盖率”工具栏按钮才可以。)

我试过像这样配置 ma​​ven-clover2-plugin:

  <plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<baseDir>${project.basedir}</baseDir>
<cloverMergeDatabase>
${project.basedir}.clover\cloverMerge.db
</cloverMergeDatabase>
</configuration>
<executions>
<execution>
<id>main</id>
<phase>package</phase>
<goals>
<goal>instrument</goal>
<goal>aggregate</goal>
<goal>check</goal>
</goals>
</execution>
<execution>
<id>site</id>
<phase>pre-site</phase>
<goals>
<goal>instrument</goal>
<goal>aggregate</goal>
<goal>check</goal>
</goals>
</execution>
<execution>
<id>clean</id>
<phase>clean</phase>
<goals><goal>clean</goal></goals>
</execution>
</executions>
</plugin>

然后我将我的项目设置配置为使用:
.clover\cloverMerge.db 并选中相对于项目目录。复选框。

但这没有用。

注意:
Configuring Instrumentation的底部它说
如果您有一个多模块项目,请不要明确设置这些位置。
所以我也尝试将该位置保留为 Maven 和 IDEA 的默认位置,但这也没有用。

也在Clover for IDEA installation GUIDE - Known Issues

If you are using the Maven build tool, you should avoid using the same > IntelliJ output directory as Maven does. As Maven uses the target/classes and target/test-classes directories,
avoid specifying these ones. The clover.db location for IntelliJ should also be distinct from that used by Maven.

为什么它们应该是不同的,是否存在文件损坏问题?如果它们保持不同,那么如何我可以获得出色的覆盖范围突出显示等,而不必在完全独立的过程中重复构建?

最佳答案

好吧,我终于找到了答案。为了后代,我把它留在这里。

解决方案很复杂,有点像 Hack,但它有效

  1. 更新父项目pom.xml文件

    • 三叶草数据库:<cloverDatabase>${project.basedir}.clover\clover.db</cloverDatabase>
    • 合并 CloverDB:
      <cloverMergeDatabase>
      ${project.basedir}.clover\cloverMerge.db
      </cloverMergeDatabase>
  2. 创建要在 IntelliJ IDEA 中运行的单元测试

    • 设置启动前 - 运行 Maven 目标
      clean clover2:setup prepare-package -DSkipTests
      Run Configuration for Unit tests screen
  3. 创建 Maven 运行配置
    • 使单元测试成为发布前条件
    • 在命令行中让 Maven 运行 clover2:aggregrate
      Run Configuration to have Maven Run the tests and aggregate the results
  4. 更新 clover 的 Intellij 项目设置以指向合并文件
    • 确保选中相对于项目目录。复选框。
    • InitString to User specified 其值与您的 pom 文件相同。
      在我的例子中:.clover\cloverMergeDB
      Settings Screen with CheckBox Checked and File name
  5. 命令运行后,只需单击Referesh Coverage 图标即可在idea 中查看和处理覆盖率数据。
    • 如果测试失败,您还可以使用漂亮的 IntelliJ 测试运行器选项卡 找出原因。

关于java - 如何在 Maven 和 IntelliJ 之间共享三叶草覆盖率数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23097106/

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