【发布时间】:2021-08-30 14:20:46
【问题描述】:
我正在尝试使用 JaCoCo 检测 groovy 脚本,但似乎 JaCoCo 只能检测 groovy 类。我可以在报告中看到脚本,但它总是以 0% 的覆盖率显示它们。 我正在使用 GroovyShell 执行测试中的脚本。似乎因为脚本的执行方式,JaCoCo 无法将源代码与测试匹配。
这是我的 JaCoCo 配置:
dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<classifier>runtime</classifier>
<scope>test</scope>
<version>0.8.7</version>
</dependency>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>
【问题讨论】:
标签: groovy jacoco jacoco-maven-plugin groovyshell