Tomcat7-maven-plugin埋め込みインスタンスでJaCoCoを使用してコード カバレッジを取得する方法はありますか?
jacoco-maven-plugin は WAR の POM で構成され、単体テストを計測しますが、jacoco エージェントを組み込みの Tomcat インスタンスにアタッチして、Tomcat に対して実行される統合テストを計測する方法がわかりません。Tomcat インスタンスが組み込まれていることを考えると、このアプローチが可能かどうかはわかりません。これを達成する他の方法はありますか?おそらく、Tomcat Maven プラグインの使用から Cargo の使用に切り替えてカバレッジを取得できますが、可能であれば Tomcat プラグインを使い続けることを好みます。
これが私のPOMからのいくつかの関連するスニペットです:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.2.201302030002</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.14</version>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<systemProperties>
<!-- as expected, this system property doesn't work since Tomcat is embedded, but this is the type of config I'm looking for -->
<JAVA_OPTS>-javaagent:${project.build.directory}/${jacoco.jar}=destfile=${project.build.directory}/jacoco.exec,append=true</JAVA_OPTS>
</systemProperties>
</configuration>
<executions>
<execution>
<id>tomcat-startup</id>
<goals>
<goal>run-war-only</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<fork>true</fork>
</configuration>
</execution>
<execution>
<id>tomcat-shutdown</id>
<goals>
<goal>shutdown</goal>
</goals>
<phase>post-integration-test</phase>
</execution>
</executions>
</plugin>
バージョン: Maven 3.0.4、Tomcat Maven Plugin 2.1、Jacoco 0.6.2.201302030002、Java 7