<目標>楽器</目標>でJaCoCo(オフライン計測)が全体のpom.xmlを分析します。しかし、私は唯一のテストの一部を必要とします

ディディエ・ロケジュネーブ:

基本的に私はjacocoのみ、機器のテストは一部を必要とするが、全体のpom.xmlをinstrumententingされ、そしてレポートがすべてに来た(「oracle.jdbc.driver」、「com.mysql.jdbc」からのデータ...など)

私はほとんどすべてで数日間しようとしてきました。しかし、私は今のところ成功していません

どのようにここにお知らせ楽器:jacoco楽器全体のpom.xml

[INFO] --- jacoco-maven-plugin:0.8.4:instrument (default-instrument) @ myApp ---
...
[DEBUG]   (f) project = MavenProject: com.firstPackage.tdz:myApp:X.1.0 @ C:\rootFolder\my_app\server\MyApp\pom.xml

そして、私のテストが実行中

[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ myApp ---
[DEBUG] Source directories: [C:\rootFolder\my_app\server\myApp\tests\src]
[DEBUG] Classpath: [C:\devel\my_app\server\myApp\target\test-classes

これは私のMavenの流れです。

[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ myApp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3582 source files to c:\rootFolder\my_app\server\myApp\target\classes
...
[INFO] --- aspectj-maven-plugin:1.3:compile (default) @ myApp ---
...
[INFO] --- jacoco-maven-plugin:0.8.4:instrument (default-instrument) @ myApp ---
...
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ myApp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 326 source files to c:\rootFolder\my_app\server\myApp\target\test-classes
...
[INFO] --- aspectj-maven-plugin:1.3:test-compile (default) @ myApp ---
...
[INFO] --- maven-surefire-plugin:2.15:test (default-test) @ myApp ---

... finally

[INFO] --- jacoco-maven-plugin:0.8.4:restore-instrumented-classes (default-restore-instrumented-classes) @ myApp ---
...
[INFO] --- jacoco-maven-plugin:0.8.4:report (default-report) @ myApp ---
[INFO] Loading execution data file c:\devel\my_app\server\MyApp\target\jacoco.exec
[INFO] Analyzed bundle 'myApp' with 5562 classes

実行は一部のみをテストするために、ここで任意の実際の例では、「Jacocoのデフォルト・楽器」で素晴らしいことです。それはその可能ですか?

<execution>
      <id>default-instrument</id>
      <goals>
         <goal>instrument</goal>
      </goals>
      <configuration>
      <!-- any real example here? Notice maven's behavior above -->
      </configuration>
  </execution>
ゴダン:

双方jacoco:instrumentjacoco:reportで動作target/classesこれが実行され、そのカバレッジ測定されるクラスであるので、。

であなたの場所場合target/classesに比べてより多くのクラスsrc、そして対応せずinclusions/ exclusions彼らはまた、インストルメントと報告されます。

クラスの除外を注意してくださいinstrumentationからクラスを除外するために十分ではありませんreport-引用JaCoCoよくある質問

レポートジェネレータは、クラスは計測から除外したり実行されなかったかを区別することはできません

だから、あなたが適切に実行設定されていることにしてください両方instrumentreportの目標をMavenのは、異なる目的の異なる実行を設定するには、多くの異なる方法を可能にする、ここで一つだけ例を示します。

<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <execution>
    <goals>
      <goal>instrument</goal>
      <goal>report</goal>
    </goals>
    <configuration>
      <!-- this configuration affects this "execution" of "instrument" and "report" goals -->
      <excludes>*</excludes>
    </configuration>
  </execution>

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=314647&siteId=1