exec-maven-plugin と jacoco を併用してコードカバレッジを測定したい。
今のところ、メイン クラスを (カバーなしで) 実行でき、単体テストのカバレッジを測定できます。メイン クラスの実行時にコード カバレッジを測定したいと考えています。
メイン クラスを実行しても問題ありません (クリーン コンパイル exec:java):
<profiles>
<profile>
<id>scenarioInitiator</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>com.mycompany.Main</mainClass>
<arguments>
<argument>123456</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
単体テスト用の jacoco 構成は問題ありません (クリーン テスト):
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<configuration>
<append>true</append>
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile> <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>