【问题标题】:Conflit between jacoco-maven-plugin and maven-surefire-pluginjacoco-maven-plugin 和 maven-surefire-plugin 之间的冲突
【发布时间】:2021-07-01 12:34:18
【问题描述】:

我同时使用jacoco-maven-plugin 和maven-surefire-plugin 时出现问题:似乎没有进行覆盖率分析!!!

为了给你更多信息,我使用jacoco-maven-plugin,它工作正常。但是我在运行测试时发现了一个性能问题,我在这里找到了解决方案:https://github.com/nats-io/nats-streaming-server/issues/698

我在我的 maven 的 pom.xml 中添加了以下部分:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <!--
                    Option used to speedup NATS tests (cf. https://github.com/nats-io/nats-streaming-server/issues/698)
                -->
                <configuration>
                    <argLine>-Djava.security.egd=file:/dev/./urandom</argLine>
                </configuration>
            </plugin>

我的性能问题得到了解决,但我意识到覆盖率分析不再进行了!!! (当然,我试图恢复我的更改:这个缺陷消失了)

在the following page 上,我看到这个缺陷已经得到处理,但是提出的解决方案(从子模块 pom 中移动“maven-surefire-plugin,并且只在父 pom 的构建部分中”)不起作用对我来说

我做了额外的测试。在我的测试运行时,我尝试检查由 maven 运行的命令行

这是我得到的:

仅指定 jacoco-maven-plugin 时:

$ ps aux | grep 'urandom\|jacoco'

pmesmeur 1477900 0.0 0.5 9181248 132192 pts/25 Sl+ 21:58 0:02 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -javaagent:/home/pmesmeur/.m2/ repository/org/jacoco/org.jacoco.agent/0.8.5/org.jacoco.agent-0.8.5-runtime.jar =destfile=/media/cersei/ssd/data/home/pmesmeur/Devel/Misys/Projects/SFX/Sandboxes/test.coverage.while.removing.maven.surefire.plugin/RemoteLpConnector/clientlib/lpconnector_integration/target/jacoco.exec,append=true -jar /media/cersei/ssd/data/home/pmesmeur/Devel/Misys/Projects/SFX/Sandboxes/test.coverage.while.removing.maven.surefire.plugin /RemoteLpConnector/clientlib/lpconnector_integration/target/surefire/surefirebooter2551385423703193145.jar /media/cersei/ssd/data/home/pmesmeur/Devel/Misys/Projects/SFX/Sandboxes/test.coverage.while.removing.maven.surefire.plugin /RemoteLpConnector/clientlib/lpconnector_integration/target/surefire 2021-06-30T21-58-25_026-jvmRun1 surefire7433391136694530406tmp su refire_06093582606115842162tmp

同时指定 jacoco-maven-plugin 和 maven-surefire-plugin 时:

$ ps aux | grep 'urandom\|jacoco'

pmesmeur 1478702 0.0 0.0 2632 772 pts/25 S+ 22:03 0:00 /bin/sh -c cd /media/cersei/ssd/data/home/pmesmeur/Devel/Misys/Projects/SFX/Sandboxes/test .coverage.while.removing.maven.surefire.plugin/RemoteLpConnector/clientlib/lpconnector_integration && /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Djava.security.egd=file:/dev /./urandom -jar /media/cersei/ssd/data/home/pmesmeur/Devel/Misys/Projects/SFX/Sandboxes/test.coverage.while.removing.maven.surefire.plugin/ RemoteLpConnector/clientlib/lpconnector_integration/target/surefire/surefirebooter4018295361004976187.jar /media/cersei/ssd/data/home/pmesmeur/Devel/Misys/Projects/SFX/Sandboxes/test.coverage.while.removing.maven.surefire.plugin/ RemoteLpConnector/clientlib/lpconnector_integration/target/surefire 2021-06-30T22-03-23_413-jvmRun1 surefire4924791797502979280tmp surefire_07998612759554882058tmp

我现在完全确定启用maven-surefire-plugin 时不会启动 jacoco

如果有人可以帮助我,我将不胜感激

最好的问候 菲利普

【问题讨论】:

    标签: java maven code-coverage maven-surefire-plugin jacoco-maven-plugin


    【解决方案1】:

    我尝试通过 maven 命令行提供argLine:

     -DargLine="-Djava.security.egd=file:/dev/./urandom"
    

    但我遇到了同样的问题

    我在以下页面找到了解决问题的方法:https://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html

    1. 定义一个&lt;property&gt;:
      <argLine>-Djava.security.egd=file:/dev/./urandom</argLine>
      
    2. 在maven-surefire-plugin 中定义一个空的&lt;configuration&gt;
      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <configuration>
              <!-- no argLine here -->
          </configuration>
      </plugin>
      

    【讨论】:

      猜你喜欢
      • 2016-10-02
      • 1970-01-01
      • 2015-09-27
      • 2016-03-05
      • 2017-05-06
      • 2015-06-18
      • 2011-03-31
      • 1970-01-01
      • 2012-02-11
      相关资源
      最近更新 更多