2015-10-06 13 views
9

私はJacocoを使ってコードカバレッジを計算するプロジェクトを持っています。 私はここのようなMavenの設定を使用:ジェンキンスとJenkins jacoco plugin empty report

http://www.petrikainulainen.net/programming/maven/creating-code-coverage-reports-for-unit-and-integration-tests-with-the-jacoco-maven-plugin/

を、私は "MVNがテストをクリーンインストール" を実行します。/target/site/jacoco-ut /フォルダーにレポートを生成します。

enter image description here

をしかし、私はジェンキンスジョブでJaCoCoカバレッジレポートを開いたときに、私は、これは以下を参照してください:私はindex.htmlファイルを開くと、私はこれを見

enter image description here

それはすべてのことを言いますテストカバーはコードの0%です。なぜ私はhtmlレポートにある同じ結果を持っていないのか分かりません。

 <plugin> 
      <groupId>org.jacoco</groupId> 
      <artifactId>jacoco-maven-plugin</artifactId> 
      <version>0.7.5.201505241946</version> 
      <executions> 
       <!-- 
        Prepares the property pointing to the JaCoCo runtime agent which 
        is passed as VM argument when Maven the Surefire plugin is executed. 
       --> 
       <execution> 
        <id>pre-unit-test</id> 
        <goals> 
         <goal>prepare-agent</goal> 
        </goals> 
        <configuration> 
         <!-- Sets the path to the file which contains the execution data. --> 
         <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile> 
         <!-- 
          Sets the name of the property containing the settings 
          for JaCoCo runtime agent. 
         --> 
         <propertyName>surefireArgLine</propertyName> 
        </configuration> 
       </execution> 
       <!-- 
        Ensures that the code coverage report for unit tests is created after 
        unit tests have been run. 
       --> 
       <execution> 
        <id>post-unit-test</id> 
        <phase>test</phase> 
        <goals> 
         <goal>report</goal> 
        </goals> 
        <configuration> 
         <!-- Sets the path to the file which contains the execution data. --> 
         <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile> 
         <!-- Sets the output directory for the code coverage report. --> 
         <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.15</version> 
      <configuration> 
       <skip>true</skip> 
      </configuration> 
      <executions> 
       <execution> 
        <id>surefire-unit-tests</id> 
        <phase>test</phase> 
        <goals> 
         <goal>test</goal> 
        </goals> 
        <configuration> 
         <!-- Sets the VM argument line used when unit tests are run. --> 
         <argLine>${surefireArgLine}</argLine> 
         <!-- Skips unit tests if the value of skip.unit.tests property is true --> 
         <skipTests>${skip.unit.tests}</skipTests> 
         <!-- Excludes integration tests when unit tests are run. --> 
         <skip>false</skip> 
         <excludes> 
          <exclude>**/*IntegrationTests.java</exclude> 
         </excludes> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-failsafe-plugin</artifactId> 
      <version>2.15</version> 
      <executions> 
       <!-- 
        Ensures that both integration-test and verify goals of the Failsafe Maven 
        plugin are executed. 
       --> 
       <execution> 
        <id>integration-tests</id> 
        <goals> 
         <goal>integration-test</goal> 
         <goal>verify</goal> 
        </goals> 
        <configuration> 
         <!-- Sets the VM argument line used when integration tests are run. --> 
         <argLine>${failsafeArgLine}</argLine> 
         <!-- 
          Skips integration tests if the value of skip.integration.tests property 
          is true 
         --> 
         <skipTests>${skip.integration.tests}</skipTests> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

そして、私のジェンキンス構成:

enter image description here

私のエラーは何ですか?

答えて

1

を私はジェンキンスさんが私の問題と同様の問題が見つかりました:

https://issues.jenkins-ci.org/browse/JENKINS-28652

エラーがjacocoバージョンによって引き起こされます。 バージョン0.7.5.201505241946が盗まれています。 私はバージョン0.7.4.201502262128のためにスイッチし、今それは動作します。

+0

OK、thx情報 –

0
Try to use in Jenkins Plugin : 
Path to exec files = **/**.exec 

と私は、このポンポン使用:

<jacoco.it.execution.data.file>${project.build.directory}/coverage-reports/jacoco-it.exec</jacoco.it.execution.data.file> 
    <jacoco.ut.execution.data.file>${project.build.directory}/coverage-reports/jacoco-ut.exec</jacoco.ut.execution.data.file> 

    <plugin> 
        <groupId>org.jacoco</groupId> 
        <artifactId>jacoco-maven-plugin</artifactId> 
        <executions> 
         <execution> 
          <id>pre-integration-test</id> 
          <phase>pre-integration-test</phase> 
          <goals> 
           <goal>prepare-agent-integration</goal> 
          </goals> 
          <configuration> 
           <destFile>${jacoco.it.execution.data.file}</destFile> 
           <propertyName>failsafeArgLine</propertyName> 
          </configuration> 
         </execution> 
         <!-- Ensures that the code coverage report for integration tests after --> 
         <!-- integration tests have been run. --> 
         <execution> 
          <id>post-integration-test</id> 
          <phase>post-integration-test</phase> 
          <goals> 
           <goal>report-integration</goal> 
          </goals> 
          <configuration> 
           <dataFile>${jacoco.it.execution.data.file}</dataFile> 
           <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 
+0

私はこれを試しましたが、私は同じ結果を持っています。 – YLombardi

+0

あなたがしている理由:mvn clean install test:mvn clean install –

+1

私が使っているチュートリアルでは「mvn clean testはユニットテストを実行し、コードカバレッジレポートを作成するので、私は "mvn clean install test"ディレクトリtarget/site/jacoco-utへの単体テスト用 "を参照してください。 – YLombardi

1

私は同様の問題を持っていたし、それは私はこれが機能を願っ2.19.1

に「Mavenの-確実な-プラグイン」バージョンを単に0.7.7.201606060606に「jacoco-のmaven-pluginの」バージョンを更新することで固定されあなたのために。

関連する問題