问题描述
所以这是一个同事称为“薛定谔错误”的东西 - 它工作正常,直到有人指出。有些东西被改变了,现在错误就在那里。改回来也无济于事-错误仍然存在:-/
在我们的 Maven 项目中,我们使用 JaCoCo 进行代码覆盖(maven-jacoco-plugin 版本 0.8.7)。 surefire 插件(版本 2.22.2)正在进行单元测试,failsave(版本 3.0.0-M5)正在进行集成测试。
这是我们的 POM:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${maven-jacoco-plugin.version}</version>
<executions>
<execution>
<id>before-unit-test-execution</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco-output/jacoco-unit-tests.exec</destFile>
<propertyName>surefire.jacoco.args</propertyName>
</configuration>
</execution>
<execution>
<id>after-unit-test-execution</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco-output/jacoco-unit-tests.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-unit-test-coverage-report
</outputDirectory>
</configuration>
</execution>
<execution>
<id>before-integration-test-execution</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco-output/jacoco-integration-tests.exec</destFile>
<propertyName>failsafe.jacoco.args</propertyName>
</configuration>
</execution>
<execution>
<id>after-integration-test-execution</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco-output/jacoco-integration-tests.exec</dataFile>
<outputDirectory>
${project.reporting.outputDirectory}/jacoco-integration-test-coverage-report
</outputDirectory>
</configuration>
</execution>
<execution>
<id>merge-unit-and-integration</id>
<phase>post-integration-test</phase>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSets>
<fileSet>
<directory>${project.build.directory}/jacoco-output/</directory>
<includes>
<include>jacoco-integration-tests.exec</include>
<include>jacoco-unit-tests.exec</include>
<!-- <include>*.exec</include>-->
</includes>
</fileSet>
</fileSets>
<destFile>${project.build.directory}/jacoco-output/merged.exec</destFile>
</configuration>
</execution>
<execution>
<id>create-merged-report</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco-output/merged.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-merged-test-coverage-report
</outputDirectory>
</configuration>
</execution>
<execution>
<id>check</id>
<goals>
<!-- check is bound to the verify phase by default -->
<goal>check</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco-output/merged.exec</dataFile>
<rules>
<rule>
<element>CLASS</element>
<excludes>
<exclude>*Test</exclude>
<exclude>configuration/*</exclude>
</excludes>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREdratIO</value>
<minimum>${jacoco.min.line.coverage}</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
<value>COVEREdratIO</value>
<minimum>${jacoco.min.branch.coverage}</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
在您看到评论部分之间 - 那是更改的部分。
现在这有时会抛出 EOFException(仅在本地运行时 - 在 Gitlab CI/CD 管道上执行时不会)。 有问题的文件是“jacoco-integration-tests.exec”。查找该文件显示,它尚未完成写入。它比文件夹中的另一个文件(“jacoco-unit-tests.exec”)小得多。
由于这个错误不是可靠地产生的(在我删除目标文件夹后它现在工作正常)我们怀疑一些竞争条件正在发生。好像 JaCoCo 仍在编写该集成测试文件,然后下一步已经想要访问它并且崩溃了。但我真的不知道,而且很难获得有关这方面的信息。不太好,如何解决。
有谁知道这个错误来自哪里以及如何修复它? 非常感谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)