문제

우리는 멀티 프로젝트에 우리는 실행하려고 Cobertura 테스트 범위를 보고서에 일부분으로 우리의 mvn 사이트를 구축.를 얻을 수 있습 Cobertura 에서 실행하는 자식 프로젝트이지만,그것은 잘못 보고서 0%적용하더라도,이 보고서는 여전히 강조 표시 라인의 코드들에 의해 타격 단위 테스트를 확인할 수 있습니다

우리가 사용하는 mvn2.0.8.가 실행 mvn clean site, mvn clean site:stagemvn clean package site.나는 테스트가 실행되는,그들은 쇼에서 확실한 보고서(모두 txt/xml 사이트 보고서).나는 누락에서 뭔가를 구성입니까?가 Cobertura 마우스 오른쪽 버튼을 작동하지 않으로 multiprojects?

이것이 부모입니다.pom:

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <inherited>true</inherited>
                <executions>
                    <execution>
                        <id>clean</id>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
<reporting>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <inherited>true</inherited>
        </plugin>
    </plugins>
</reporting>

했는데 그것을 실행하지 않고 다음에는 아이입니다.딩:

    <reporting>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
        </plugin>
    </plugins>
</reporting>

나이에 출력의 구축:

...
[INFO] [cobertura:instrument]
[INFO] Cobertura 1.9 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Instrumenting 3 files to C:\workspaces\sandbox\CommonJsf\target\generated-classes\cobertura
Cobertura: Saved information on 3 classes.
Instrument time: 186ms

[INFO] Instrumentation was successful.
...
[INFO] Generating "Cobertura Test Coverage" report.
[INFO] Cobertura 1.9 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Cobertura: Loaded information on 3 classes.
Report time: 481ms

[INFO] Cobertura Report generation was successful.

과 보고서는 다음과 같이 표시됩니다.cobertura report

도움이 되었습니까?

해결책

내가 심는 당신이 놓치의 실행 cobertura 플러그인 중에 컴파일 단계는 코드만을 계측하여 보고 플러그인,사이트에서 수명 주기후 테스트를 실행 되었습니다.그래서 시험을 실행하지 않을 픽업하기 때문에 그들은 실행에 비된 코드입니다.분석의 구축을 로그에 더 신중하게하는 경우 내가 옳다는 것을 알 수 있는 확실한 테스트 실행하기 전에 cobertura:악기입니다.

내 구성과 유사,당신만을 지정하는 것 외에도 정 exectution 에 pluginManagement(처럼 가),나를 지정 cobertura 플러그인에서 명시적으로 구축 플러그인 섹션:

  <build>
  ...
    <plugins>
    ...
      <plugin>
        <inherited>true</inherited>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>${cobertura.plugin.version}</version>
      </plugin>
    </plugins>
  </build>

내 구성의 몸이 작동하고 모든 Cobertura 물건은 글로벌 조직 전체 pom,는 모든 프로젝트의 사용으로 부모입니다.

이 방법은 프로젝트를 지정하지 않은 아무것도 Cobertura-에서 관련된 그들의 pom.xml's 지만,그들은 아직도 생성 범위를 보고합니다.

다른 팁

가 성공적으로 얻기에 Cobertura 결합하는 보고에서는 멀티 프로젝트입니다.이에서 문제가 일반으로 멀티-프로젝트 reporting.

리 평가 수중 음파 탐지기 으로 솔루션에 대한 우리의 통계 보고입니다.그것은 훌륭한 일을 하의 제공을 요약 통계에 걸쳐 프로젝트를 포함하여 다중 proijects.

이 솔루션을 구현해 내는 다소 수동,하지만 작동합니다.그것은 몇 가지 단계로 구성되어 있는 하나의 단계를 결합하는 여러 가지입니다.ser 파일을 생성하는 Cobertura.이를 사용하여 수행할 수 있습니 cobertura-병합된 명령행 도구는 내부 maven 작업입니다.

출력에 따라 당신은 쇼가 있는 파일을 실제로는 계측,그것을 알려주는 3 개의 파일을 계측됩니다.

@마르코가 오른쪽으로,그것은 가능하지 않은 이를 달성하기 위해 일반적으로 통 maven 만으로 maven cobertura plugin 병합 목표입니다.

를 달성할 수 있습을 통해 그것의 혼합 maven 및 ant 목표: http://thomassundberg.wordpress.com/2012/02/18/test-coverage-in-a-multi-module-maven-project/

그럼에도 불구하고,경우에 당신은 하나의 단일 프로젝트 undertest 없이 필요합니다.당신이 할 수 테스트 프로젝트에서 복사합니다.ser 파일 및 계측 클래스에서는 프로젝트에서 테스트:

//in test project
<plugin> 
<groupId>com.github.goldin</groupId>
<artifactId>copy-maven-plugin</artifactId>
<version>0.2.5</version>
<executions>
    <execution>
    <id>copy-cobertura-data-from-project-under-test</id>
    <phase>compile</phase>
    <goals>
        <goal>copy</goal>
    </goals>
    <configuration>
    <resources>
        <resource>
                        <directory>${project.basedir}/../<project-under-test>/target/cobertura</directory>
                            <targetPath>${project.basedir}/target/cobertura</targetPath>
                <includes>                  
                              <include>*.ser</include>
                </includes>
           </resource>
           <resource>
                    <directory>${project.basedir}/../<project-under-test>/target/generated-classes/cobertura/</directory>
                    <targetPath>${project.basedir}/target/generated-classes/cobertura</targetPath>
                    <preservePath>true</preservePath>
           </resource>
        </resources>
            </configuration>
        </execution>
</executions>
</plugin>

//in parent project
<build>
<plugins>
    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <configuration>
        <format>xml</format>
        <aggregate>true</aggregate>
    </configuration>
    <executions>
        <execution>
                    <goals>
                <goal>clean</goal>
            </goals>
        </execution>
    </executions>
</plugin>
    </plugins>
</build>
<reporting>
<plugins>
    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <version>${cobertura.version}</version>
        </plugin>
</plugins>
 </reporting>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top