2016-03-22 18 views
1

コードカバレッジの数値がかなり低いプロジェクトがあります。深いダイビングをした後、私はジャコココードカバレッジの統計がsrcの代わりにターゲットdirectoyに依存していることを知りました。コードカバレッジから生成されたソースを除外します。

target/generated-sources/delombok/com/ 

対象のディレクトリを除外すると、カバレッジは0%になります。だから、対象となるフォルダではなく、コード(src)に対して測定されるべきコードカバレッジはありません。以下はSonarQubeのスクリーンショットです。

enter image description here

そこで質問は、私は、コードカバレッジではなく、ターゲットのSRCのために測定されていることを確認しない方法ですか?

後は、依存関係のないポンポンです:

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 

    <modelVersion>4.0.0</modelVersion> 

    <groupId>removed</groupId> 
    <artifactId>xxxx</artifactId> 
    <version>0.0.11-SNAPSHOT</version> 
    <packaging>war</packaging> 



    <build> 

     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>cassandra-maven-plugin</artifactId> 
       <version>2.1.7-1</version> 
       <configuration> 
        <script>${basedir}/src/main/cassandra/local_run.cql</script> 
        <cqlVersion>3.2.0</cqlVersion> 
        <startNativeTransport>true</startNativeTransport> 
        <nativeTransportPort>9142</nativeTransportPort> 
        <jmxPort>17199</jmxPort> 
        <storagePort>17000</storagePort> 
        <loadFailureIgnore>false</loadFailureIgnore> 
        <cuLoadFailureIgnore>false</cuLoadFailureIgnore> 
       </configuration> 
       <executions> 
        <execution> 
         <id>start</id> 
         <goals> 
          <goal>start</goal> 
          <goal>load</goal> 
         </goals> 
         <phase>process-classes</phase> <!--Bind cassandra start and load to process-classes which is the phase that is called up before tomcat is run --> 
        </execution> 
        <execution> 
         <id>stop</id> 
         <goals> 
          <goal>stop</goal> 
         </goals> 
         <!--Bind cassandra stop to generate-test-sources which is the phase that is called up before 
         tests are run. This is because our tests start their own cassandra --> 
         <phase>integration-test</phase> 
        </execution> 
       </executions> 
       <dependencies> 
        <dependency> 
         <groupId>org.slf4j</groupId> 
         <artifactId>slf4j-log4j12</artifactId> 
         <version>1.7.7</version> 
        </dependency> 
       </dependencies> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-release-plugin</artifactId> 
      </plugin> 

      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
      </plugin> 

      <plugin> 
       <groupId>org.projectlombok</groupId> 
       <artifactId>lombok-maven-plugin</artifactId> 
      </plugin> 
      <!--Needed to add this so that src/main/java is recognized as a source folder --> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>build-helper-maven-plugin</artifactId> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-source-plugin</artifactId> 
      </plugin> 

      <!-- Unit Test --> 


      <!-- Integration Test --> 


      <plugin> 
       <artifactId>maven-enforcer-plugin</artifactId> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>2.4</version> 
       <configuration> 
        <warName>activationloginedge</warName> 
       </configuration> 
      </plugin> 

      <!-- Tomcat Integration Test --> 
      <plugin> 
       <groupId>org.apache.tomcat.maven</groupId> 
       <artifactId>tomcat7-maven-plugin</artifactId> 
       <configuration> 
        <path>/activationloginedge</path> 
       </configuration> 
       <executions> 
        <execution> 
         <id>tomcat-run</id> 
         <goals> 
          <goal>run</goal> 
         </goals> 
         <phase>pre-integration-test</phase> 
         <configuration> 
          <systemProperties> 
           <!-- We want test configuration for running integration tests. --> 
           <archaius.deployment.environment>test</archaius.deployment.environment> 
           <logback-lib.env>filesystem</logback-lib.env> 
          </systemProperties> 
          <fork>true</fork> 
         </configuration> 
        </execution> 
        <execution> 
         <id>tomcat-shutdown</id> 
         <goals> 
          <goal>shutdown</goal> 
         </goals> 
         <phase>post-integration-test</phase> 
        </execution> 
       </executions> 
      </plugin> 
     <plugin> 
     <groupId>org.jacoco</groupId> 
     <artifactId>jacoco-maven-plugin</artifactId> 
     <version>0.7.4.201502262128</version> 
     <executions> 
     <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}/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}/jacoco-ut.exec</dataFile> 
      <!-- Sets the output directory for the code coverage report. --> 
      <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory> 
      </configuration> 
</execution>  <execution> 
<id>pre-integration-test</id> 
<phase>pre-integration-test</phase> 
<goals> 
    <goal>prepare-agent</goal> 
</goals> 
<configuration> 
<!-- Sets the path to the file which contains the execution data. --> 
    <destFile>${project.build.directory}/jacoco-it.exec</destFile> 
    <!-- Sets the name of the property containing the settings for JaCoCo runtime agent.--> 
    <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</goal> 
     </goals> 
    <configuration> 
    <!-- Sets the path to the file which contains the execution data. --> 
    <dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile> 
    <!-- Sets the output directory for the code coverage report. --> 
      <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory> 
     </configuration> 
    </execution> 
    </executions> 
    </plugin> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-surefire-plugin</artifactId> 
     <version>2.12.4</version> 
     <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. --> 
     <excludes> 
      <exclude>**/IT*.java</exclude> 
     </excludes> 
     </configuration> 
     </plugin> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-failsafe-plugin</artifactId> 
      <version>2.15</version>  <executions> 
      <execution> 
       <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> 
    </plugins> 
     </build> 
    </project> 
+1

設定の詳細を教えてください。実際、コードカバレッジはソースコードに対して計算されるため、「ターゲット」をソースフォルダの1つに設定したように見えます。 –

+0

依存関係の部分を削除してpomを添付しました – Jeel

+0

あなたはファイルを添付するのを忘れたようですね。@Jeel –

答えて

1

OKは、ロンボクMavenプラグインをビルドするMavenの中にソースフォルダのリストを変更し、target/generated-sources/delombokフォルダがソースフォルダとしてSonarQubeによって認識されている理由です。

のみ、独自のソース・ファイルを検討するSonarQubeを強制するためには、あなたのPOMに次のプロパティを追加する必要があります

<properties> 
    <sonar.sources>src/main/java</sonar.sources> 
</properties> 

これはあなたの問題を解決します。

関連する問題