JaCoCo 실행시 "실행 데이터 파일 누락으로 인해 JaCoCo 실행 건너 뛰기"받기
Maven 3.0.3, JUnit 4.8.1 및 Jacoco 0.6.3.201306030806을 사용하고 있으며 테스트 커버리지 보고서를 만들려고합니다.
단위 테스트 만있는 프로젝트가 있지만 보고서를 실행할 수 없습니다. 다음을 실행할 Skipping JaCoCo execution due to missing execution data file
때 오류가 반복적으로 나타납니다.
mvn clean install -P test-coverage
내 pom이 구성되는 방법은 다음과 같습니다.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<reuseForks>true</reuseForks>
<argLine>-Xmx2048m</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<reuseForks>true</reuseForks>
<argLine>-Xmx4096m -XX:MaxPermSize=512M ${itCoverageAgent}</argLine>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
...
<profile>
<id>test-coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.3.201306030806</version>
<configuration>
<destfile>${basedir}/target/coverage-reports/jacoco-unit.exec</destfile>
<datafile>${basedir}/target/coverage-reports/jacoco-unit.exec</datafile>
</configuration>
<executions>
<execution>
<id>prepare-unit-tests</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- prepare agent for measuring integration tests -->
<execution>
<id>prepare-integration-tests</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<propertyName>itCoverageAgent</propertyName>
</configuration>
</execution>
<execution>
<id>jacoco-site</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
내 모든 테스트가 성공적으로 실행되었습니다. 다음은 Maven의 일부 출력입니다.
[INFO] --- jacoco-maven-plugin:0.6.2.201302030002:prepare-agent (prepare-unit-tests) @ myproject ---
[INFO] argLine set to -javaagent:/Users/davea/.m2/repository/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002-runtime.jar=destfile=/Users/davea/Dropbox/workspace/myproject/target/jacoco.exec
[INFO]
...
Tests run: 14, Failures: 0, Errors: 0, Skipped: 0
[INFO]
...
[INFO]
[INFO] --- jacoco-maven-plugin:0.6.2.201302030002:prepare-agent (prepare-integration-tests) @ myproject ---
[INFO] itCoverageAgent set to -javaagent:/Users/davea/.m2/repository/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002-runtime.jar=destfile=/Users/davea/Dropbox/workspace/myproject/target/jacoco.exec
[INFO]
[INFO] --- maven-failsafe-plugin:2.14.1:integration-test (default) @ myproject ---
[WARNING] File encoding has not been set, using platform encoding MacRoman, i.e. build is platform dependent!
[INFO]
[INFO] --- maven-failsafe-plugin:2.14.1:verify (default) @ myproject ---
[INFO] Failsafe report directory: /Users/davea/Dropbox/workspace/myproject/target/failsafe-reports
[WARNING] File encoding has not been set, using platform encoding MacRoman, i.e. build is platform dependent!
[INFO]
[INFO] --- jacoco-maven-plugin:0.6.2.201302030002:report (jacoco-site) @ myproject ---
[INFO] Skipping JaCoCo execution due to missing execution data file
[INFO]
내가 놓친 구성에 대한 아이디어가 있습니까?
jacoco-maven-plugin : 0.7.10-SNAPSHOT
에서 jacoco : 에이전트 준비 말한다 :
maven-surefire-plugin의 경우이를 수행하는 방법 중 하나는 후기 속성 평가에 구문을 사용하는 것입니다.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <argLine>@{argLine} -your -extra -arguments</argLine> </configuration> </plugin>
에 @{argLine}
추가됩니다 -your -extra -arguments
.
의견 변경 및 보고에 대해 Slava Semushin 에게 감사드립니다 .
jacoco-maven-plugin : 0.7.2-SNAPSHOT
다음과 같은 jacoco : prepare-agent 를 따릅니다 .
[org.jacoco : jacoco-maven-plugin : 0.7.2-SNAPSHOT : prepare-agent] 테스트중인 애플리케이션에 VM 인수로 전달할 수있는 JaCoCo 런타임 에이전트를 가리키는 속성을 준비합니다. 기본적으로 프로젝트 패키징 유형에 따라 다음 이름의 속성이 설정됩니다.
- eclipse-test-plugin 패키징 유형에 대한 tycho.testArgLine 및
- 그렇지 않으면 argLine.
이러한 속성은 테스트 구성으로 덮어 쓰지 않아야합니다. 그렇지 않으면 JaCoCo 에이전트를 연결할 수 없습니다. 맞춤 매개 변수가 필요한 경우 추가하세요. 예를 들면 :
<argLine>${argLine} -your -extra -arguments</argLine>
결과 범위 정보는 실행 중에 수집되며 기본적으로 프로세스가 종료 될 때 파일에 기록됩니다.
maven-surefire-plugin
플러그인 구성에서 다음 행을 변경해야 합니다 ( ${argLine}
내부 참고 <argLine>
).
<argLine>-Xmx2048m</argLine>
에
<argLine>${argLine} -Xmx2048m</argLine>
다른 플러그인에도 필요한 사항을 변경 maven-failsafe-plugin
하고 다음을 교체합니다 (다시 확인 ${argLine}
).
<argLine>-Xmx4096m -XX:MaxPermSize=512M ${itCoverageAgent}</argLine>
에
<argLine>${argLine} -Xmx4096m -XX:MaxPermSize=512M ${itCoverageAgent}</argLine>
동일한 오류를 반환하는 약간 다른 문제에 직면했습니다.
Skipping JaCoCo execution due to missing execution data /target/jacoco.exec
사실이 오류는 여러 가지 이유로 반환됩니다. Stack Overflow에서 다양한 솔루션을 실험했지만이 리소스 가 가장 좋습니다. Jacoco가 동일한 오류를 반환 할 수있는 여러 가지 잠재적 인 이유를 분석합니다.
우리에게 해결책은 구성에 준비 에이전트를 추가하는 것이 었습니다.
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
I would imagine most users will be experiencing it for different reasons, so take a look at the aforementioned resource!
There might a case where some other argline setup or plugin in pom may be overriding jacoco execution order setup.
argLine set to -javaagent:/Users/davea/.m2/repository/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002-runtime.jar=destfile=/Users/davea/Dropbox/workspace/myproject/target/jacoco.exec
One of the example
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<forkCount>5</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Dnet.sf.ehcache.disabled=true</argLine>
</configuration>
</plugin>
After getting rid of argLine from these plugins, jacoco started to work normally.
One can also get "Skipping JaCoCo execution due to missing execution data file" error due to missing tests in project. For example when you fire up new project and have no *Test.java files at all.
FWhat tdrury said:
change your plugin configuration into this:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.3.201306030806</version>
<executions>
<!-- prepare agent for measuring integration tests -->
<execution>
<id>prepare-integration-tests</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
</configuration>
</execution>
<execution>
<id>jacoco-site</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
</configuration>
</execution>
</executions>
</plugin>
Edit: Just noticed one important thing, destFile and dataFile seems case sensitive so it's supposed to be destFile, not destfile.
I know this question is pretty old but if someone like me comes here looking for an answer then this might help. I have been able to overcome the above error with this.
1) Remove the below piece of code from the plugin maven-surefire-plugin
<reuseForks>true</reuseForks>
<argLine>-Xmx2048m</argLine>
2) Add the below goal:
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
I have added a Maven/Java project with 1 Domain class with the following features:
- Unit or Integration testing with the plugins Surefire and Failsafe.
- Findbugs.
- Test coverage via Jacoco.
Where are the Jacoco results? After testing and running 'mvn clean', you can find the results in 'target/site/jacoco/index.html'. Open this file in the browser.
Enjoy!
I tried to keep the project as simple as possible. The project puts many suggestions from these posts together in an example project. Thank you, contributors!
The execution says it's putting the jacoco data in /Users/davea/Dropbox/workspace/myproject/target/jacoco.exec but your maven configuration is looking for the data in ${basedir}/target/coverage-reports/jacoco-unit.exec.
My response is very late but for others users In your case you have to configure failsafe pluging to use the command line agent configuration saved in itCoverageAgent variable. For exemple
<configuration>
<argLine>${itCoverageAgent}</argLine>
</configuration>
In your maven configuration, jacoco prepare the command line arguments in prepare-agent phase, but failsafe plugin doesn't use it so there is no execution data file.
Try to use:
mvn jacoco:report -debug
to see the details about your reporting process.
I configured my jacoco like this:
<configuration>
<dataFile>~/jacoco.exec</dataFile>
<outputDirectory>~/jacoco</outputDirectory>
</configuration>
Then mvn jacoco:report -debug
shows it using the default configuration, which means jacoco.exec
is not in ~/jacoco.exec
. The error says missing execution data file
.
So just use the default configuration:
<execution>
<id>default-report</id>
<goals>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
</configuration>
</execution>
And everything works fine.
Sometimes the execution runs first time, and when we do maven clean install it doesn't generate after that. The issue was using true for skipMain and skip properties under maven-compiler-plugin of the main pom File. Remove them if they were introduced as a part of any issue or suggestion.
I've tried all answers but only the following combination of advice has worked for me. Why? I had very specific requirements:
- JaCoCo generates report when build is run from command line:
mvn clean verify
(Maven 3.6.0) - Intellij IDEA (2019.01) runs my tests as well
- It all works in presence of another
javaagent
defined insurefire
plugin
Solution - prepend argLine
value in surefire
configuration with "late replacement" maven property @{...}
as explained in surefire
FAQ (my fixed configuration)
How do I use properties set by other plugins in argLine? Maven does property replacement for
${...} values in pom.xml before any plugin is run. So Surefire would never see the place-holders in its argLine property. Since the Version 2.17 using an alternate syntax for these properties,
@{...} allows late replacement of properties when the plugin is executed, so properties that have been modified by other plugins will be picked up correctly.
Failed first try - define jaCoCoArgLine property in prepare-agent
goal configuration of jacoco
- the scenario failed my second requirement, IntelliJ IDEA couldn't figure out agent for jmockit I use in the project for static method mocking
I struggled for days. I tried all the different configurations suggested in this thread. None of them works. Finally, I find only the important configuration is the prepare-agent goal. But you have to put it in the right phase. I saw so many examples put it in the "pre-integration-test", that's a misleading, as it will only be executed after unit test. So the unit test won't be instrumented.
The right config should just use the default phase, (don't specify the phase explicitly). And usually, you don't need to mass around maven-surefire-plugin.
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
'program tip' 카테고리의 다른 글
Angular.js : .value ()는 앱 전체 상수를 설정하는 적절한 방법이며 컨트롤러에서 검색하는 방법입니다. (0) | 2020.09.12 |
---|---|
LESS에 "확장"기능이 있습니까? (0) | 2020.09.12 |
std :: array의 기본 초기화? (0) | 2020.09.12 |
GitHub 페이지 빌드를 강제하는 방법은 무엇입니까? (0) | 2020.09.12 |
AnyObject and Any in Swift (0) | 2020.09.12 |