2017-01-23 8 views
-1

Arquillian으로 Jacoco 코드 커버리지를 사용하는 사람이 있습니까? 내 프로젝트는 멀티 모듈 프로젝트이며 현재 Arquillian 테스트의 코드 커버리지를 보여주지 않습니다. 아래 변경 사항 이외의 Arquillian.xml에 추가 변경 사항이 있습니까? 내 치어 XML의다중 모듈 프로젝트에서 Arquillian으로 Jacoco 코드 커버리지

빌드 및 플러그인 부분은 올바른 솔루션에 저를 가리키는 위해

<build> 
    <plugins> 

     <!-- start Jacoco --> 

<plugin> 
    <groupId>org.jacoco</groupId> 
    <artifactId>jacoco-maven-plugin</artifactId> 
    <version>0.7.4.201502262128</version> 
    <configuration> 
     <propertyName>coverageAgent</propertyName> 
     <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> 
       <append>true</append> 
      </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.basedir}/../target/coverageReport</outputDirectory> 
       <append>true</append> 
      </configuration> 
     </execution> 
     <execution> 
      <id>pre-integration-test</id> 
      <phase>pre-integration-test</phase> 
      <goals> 
       <goal>prepare-agent</goal> 
      </goals> 
      <configuration> 
       <destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile> 
       <propertyName>failsafeArgLine</propertyName> 
      </configuration> 
     </execution> 
     <execution> 
      <id>post-integration-test</id> 
      <phase>post-integration-test</phase> 
      <goals> 
       <goal>report</goal> 
      </goals> 
      <configuration> 
       <append>true</append> 
       <dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile> 
       <outputDirectory>${project.basedir}/../target/coverageReport</outputDirectory> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <version>${maven.surefire.version}</version> 
    <configuration> 
     <argLine>${surefireArgLine}</argLine> 
     <includes> 
      <include>**/*TestNG*</include> 
     </includes> 
     <excludes> 
      <exclude>**/Test/**</exclude> 
      <exclude>**/*IT*</exclude> 
     </excludes> 
    </configuration> 
</plugin> 

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-failsafe-plugin</artifactId> 
    <version>2.7.1</version> 
    <configuration> 
     <argLine>${failsafeArgLine}</argLine> 
     <includes> 
      <include>**/*Test*</include> 
     </includes> 
    </configuration> 
</plugin> 


    </plugins> 
    </build> 


<profiles> 
    <profile> 
     <id>jacoco-integ-tests</id> 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-failsafe-plugin</artifactId> 
        <version>2.7.1</version> 
        <configuration> 
         <argLine>${failsafeArgLine}</argLine> 
         <includes> 
          <include>**/*Test*</include> 
         </includes> 
         <properties> 
          <property> 
           <name>listener</name> 
           <value>org.sonar.java.jacoco.JUnitListener</value> 
          </property> 
         </properties> 
        </configuration> 
        <executions> 
          <execution> 
           <id>integration-tests</id> 
           <goals> 
            <goal>integration-test</goal> 
            <goal>verify</goal> 
           </goals> 
           <configuration> 
            <argLine>${failsafeArgLine}</argLine> 
            <properties> 
           <property> 
            <name>listener</name> 
            <value>org.sonar.java.jacoco.JUnitListener</value> 
           </property> 
          </properties> 
            <skipTests>false</skipTests> 
           </configuration> 
          </execution> 
         </executions> 
       </plugin> 
      </plugins> 
     </build> 
     <dependencies> 
      <dependency> 
       <groupId>org.codehaus.sonar-plugins.java</groupId> 
       <artifactId>sonar-jacoco-listeners</artifactId> 
       <version>2.6</version> 
       <scope>test</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.jacoco</groupId> 
       <artifactId>org.jacoco.core</artifactId> 
       <version>${version.jacoco}</version> 
       <scope>test</scope> 
       </dependency> 
       <dependency> 
       <groupId>org.jboss.arquillian.extension</groupId> 
       <artifactId>arquillian-jacoco</artifactId> 
       <version>1.0.0.Alpha9</version> 
       <scope>test</scope> 
       </dependency> 

     </dependencies> 
    </profile> 

    <profile> 
     <id>jacoco-unit-tests</id> 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-surefire-plugin</artifactId> 
        <version>2.13</version> 
        <configuration> 
         <argLine>${surefireArgLine}</argLine> 
         <properties> 
          <property> 
           <name>listener</name> 
           <value>org.sonar.java.jacoco.TestNGListener</value> 
          </property> 
         </properties> 
         <includes> 
          <include>**/*TestNG*</include> 
         </includes> 
         <excludes> 
          <exclude>**/FT/**</exclude> 
          <exclude>**/*IT*</exclude> 
         </excludes> 
        </configuration> 
       </plugin> 
      </plugins> 
     </build> 
     <dependencies> 
      <dependency> 
       <groupId>org.codehaus.sonar-plugins.java</groupId> 
       <artifactId>sonar-jacoco-listeners</artifactId> 
       <version>2.6</version> 
       <scope>test</scope> 
      </dependency> 
     </dependencies> 
    </profile> 
</profiles> 
+0

다중 모듈 Maven 프로젝트의 [Jacoco 및 Arquillian]의 가능한 복제본 (http://stackoverflow.com/questions/12354669/jacoco-and-arquillian-in-a-multi-module-maven-project) – Godin

+0

I 이 질문을 게시하기 전에이 게시물을 참조하십시오. 여전히 작동하지 않습니다. – Raj

+0

'pom.xml'의 잘린 부분만으로는 문제를 재현하기에 충분하지 않습니다. 완전한 실행 가능한 예 (http://stackoverflow.com/help/mcve)를 제공해주십시오 - 그러면 여기에 도움을받을 수있는 가능성과 속도가 크게 높아질 것입니다. – Godin

답변

0

감사 @Godin 이하입니다. 나는 아래 두 단계를 추가하여 그것을 해결했다.

1) 통합 테스트가

<plugin> 
     <groupId>org.jacoco</groupId> 
     <artifactId>jacoco-maven-plugin</artifactId> 
      <version>0.7.8</version> 
     <executions> 
      <execution> 
      <configuration> 
       <destFile>${project.build.directory}/jacoco.exec</destFile> 
      </configuration> 
      </execution> 
      <execution> 
      <id>it-report</id> 
      <phase>verify</phase> 
      <goals>   
       <goal>report-aggregate</goal> 
      </goals> 
      <configuration> 
      <!-- <dataFileIncludes>**/jacoco.exec</dataFileIncludes> --> 
       <outputDirectory>${project.build.directory}/coverage-reports/jacoco</outputDirectory> 
      </configuration> 
      </execution> 
     </executions> 
     </plugin> 

키 대신에 우리가 "보고서"의 "보고 집계"목표를 사용할 필요가있다 실행 자식 치어에서 부모 치어

<plugin> 
     <groupId>org.jacoco</groupId> 
     <artifactId>jacoco-maven-plugin</artifactId> 
     <version>0.7.8</version> 
     <configuration> 
      <destFile>${sonar.jacoco.itReportPath}</destFile> 
      <append>true</append> 
     </configuration> 
     <executions> 
      <execution> 
      <goals> 
       <goal>prepare-agent</goal> 
       <goal>report</goal> 
      </goals> 
      </execution> 
     </executions> 
     </plugin> 

2). "보고서 집계"목표는 다중 모듈 코드 범위를 처리 할 수 ​​있습니다.