質問: jacoco maven プラグインを構成して、カスタム パッケージに関連するカバレッジ レポートを表示するにはどうすればよいですか? (デフォルトのものではありません:実行中のクラスのパッケージ)。
プロジェクトの構造:
testprj
|
+ -- pom.xml // parent pom
|
+ -- starter // Aggregates (as dependencies) all other modules
| +
| |
| + /src/main/java/com/my/prj/testprj/starter/MainApplication.java // Springboot starter cls
| |
| + /src/test/java/com/my/prj/testprj/starter/ProjectIT.java // Integration tests
| |
| + -- pom.xml
|
+ -- core // acts as a controller
| +
| |
| + ...
| |
| + -- pom.xml
|
+ -- dbmock
| +
| |
| + ...
| |
| + -- pom.xml
|
+ -- gateway // REST endpoint
| +
| |
| + ...
| |
| + -- pom.xml
|
+ target/coverage/jacoco-it/jacoco-it.exec
|
+ ...
|
+ index.html // Jacoco Coverage Report
ジャココ構成:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</version>
<executions>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<append>true</append>
<propertyName>jacoco.agent.it.arg</propertyName>
<destFile>${session.executionRootDirectory}/target/coverage/jacoco-it/jacoco-it.exec</destFile>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report-integration</goal>
</goals>
<configuration>
<dataFile>${session.executionRootDirectory}/target/coverage/jacoco-it/jacoco-it.exec</dataFile>
<outputDirectory>${session.executionRootDirectory}/target/coverage/jacoco-it</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
フェイルセーフ構成:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19</version>
<configuration>
<argLine>${jacoco.agent.it.arg}</argLine>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
備考 :
1) クラスパス内の他のすべてを集約する中央モジュールからすべてのテストを実行し、すべてで同じパッケージプレフィックスを使用することにより、マルチモジュール環境の jacoco maven プラグインでサポートされていない集約機能を回避しようとしましたそれらのcom/my/prj/testprj/
2)問題 : com/my/prj/testprj/starterパッケージ (テスト クラスを含むパッケージ) のカバレッジ レポートが表示されます。com/my/prj/testprj/に対するカバレッジを表示したい
3) IntelliJIdea IDE は、カバレッジ データを記録するパッケージを指定できるようにすることで (Jacoco を使用して) これを簡単にサポートします。以下を参照してください。