2011-11-04 24 views
7

Sau khi đọc bài viết này: What is the proper way to use Cobertura with Maven 3.0.2 và điều này: http://www.wakaleo.com/blog/292-site-generation-in-maven-3Cobertura đang phủ sóng là 0% khi sử dụng Maven 3

tập tin POM của tôi trông như thế này:

<build> 
    <plugins> 
     ..... 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-site-plugin</artifactId> 
      <version>3.0</version> 
      <configuration> 
       <reportPlugins> 
        <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-javadoc-plugin</artifactId> 
         <version>2.7</version> 
        </plugin> 
        <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-jxr-plugin</artifactId> 
         <version>2.1</version> 
         <configuration> 
          <aggregate>true</aggregate> 
         </configuration> 
        </plugin> 
        <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-surefire-report-plugin</artifactId> 
         <version>2.6</version> 
         <configuration> 
          <skip>true</skip> 
          <useFile>false</useFile> 
          <argLine>-Xmx512m</argLine> 
          <systemProperties> 
           <property> 
            <name>generateReport</name> 
            <value>html</value> 
           </property> 
          </systemProperties> 
         </configuration> 
         <executions> 
          <execution> 
           <id>unit-test</id> 
           <phase>test</phase> 
           <goals> 
            <goal>test</goal> 
           </goals> 
           <configuration> 
            <skip>false</skip> 
            <includes> 
             <include>**/UnitTest*.java</include> 
             <include>**/*UnitTest.java</include> 
             <include>**/*Scenarios.java</include> 
            </includes> 
           </configuration> 
          </execution> 
          <execution> 
           <id>integration-test</id> 
           <phase>test</phase> 
           <goals> 
            <goal>test</goal> 
           </goals> 
           <configuration> 
            <skip>${integrationTestsSkip}</skip> 
            <includes> 
             <include>**/*IntegrationTest.java</include> 
            </includes> 
           </configuration> 
          </execution> 
         </executions> 
        </plugin> 
        <plugin> 
         <groupId>org.codehaus.mojo</groupId> 
         <artifactId>cobertura-maven-plugin</artifactId> 
         <version>2.5.1</version> 
         <configuration> 
          <instrumentation> 
           <includes> 
            <include>**/UnitTest*.class</include> 
            <include>**/*UnitTest.class</include> 
            <include>**/*Scenarios.class</include> 
           </includes> 
          </instrumentation> 
         </configuration> 
         <executions> 
          <execution> 
           <id>clean</id> 
           <phase>pre-site</phase> 
           <goals> 
            <goal>clean</goal> 
           </goals> 
          </execution> 
          <execution> 
           <id>instrument</id> 
           <phase>site</phase> 
           <goals> 
            <goal>instrument</goal> 
            <goal>cobertura</goal> 
           </goals> 
          </execution> 
         </executions> 
        </plugin> 
        <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-checkstyle-plugin</artifactId> 
         <version>2.6</version> 
        </plugin> 
       </reportPlugins> 
      </configuration> 
     </plugin> 

     ...... 



    </plugins> 
</build> 

Sau khi chạy Cobertura: Cobertura tôi vẫn không nhận được bất kỳ báo cáo nào. Trong thư mục cobertura mục tiêu trống và không có thư mục được gọi là trang web. Bất cứ ai có thể cho tôi biết tôi đã làm gì sai? Khi tôi đã được sử dụng cách tiếp cận cũ với maven 2.2 tất cả mọi thứ làm việc tốt nhưng M3 tôi đã nhận được kết quả xấu.

+1

Bạn có thể xem các tập tin cobertura.ser bất cứ nơi nào trong xây dựng thư mục của bạn? Đây là những gì báo cáo được xây dựng từ để kiểm tra đường dẫn thư mục của bạn. Nếu tệp đó không tồn tại thì các lớp được thiết kế của bạn sẽ được tạo trong thư mục build của bạn? – Brad

Trả lời

1

Ok, đã giải quyết được sự cố. Kỳ lạ sau khi một vài làm mới và xây dựng lại tất cả mọi thứ bắt đầu làm việc tốt. Tệp Ser đã có trong thư mục và bây giờ tất cả các báo cáo được tạo chính xác. Tôi khá ngạc nhiên bởi điều đó :)

+0

nó không có vẻ là giải pháp, nó cũng không hoạt động cho tôi –

+1

làm thế nào để giải quyết nó? nó vẫn còn 0 không có vấn đề referhes, rebuilds – Stella

1

Ok, những gì tôi đã tìm thấy nó là có thể phải bao gồm rõ ràng **/* Test.java trong phần cấu hình của maven-surefire-plugin khi định cấu hình các thực thi đặc biệt trong phụ huynh pom hoặc khi sử dụng một phụ huynh ở tất cả ..... otherweise nó đã không thực hiện bất kỳ kiểm tra chắc chắn ở tất cả trong quá trình thực hiện cobertura và các báo cáo luôn luôn cho thấy không có bảo hiểm.

Các vấn đề liên quan