từ quan điểm của tôi, các Cobertura maven Plugin có hai nhược điểm lớn. Nó có không có mục tiêu báo cáo duy nhất, tất cả các bài kiểm tra đơn vị sẽ chạy bên cạnh chắc chắn một lần nữa. Nó tạo phạm vi mã cho các bài kiểm tra đơn vị chỉ.
Tôi đang sử dụng plugin JaCoCo maven ngay bây giờ. JaCoCo sử dụng lại các báo cáo chắc chắn và/hoặc báo cáo không an toàn để tạo phạm vi mã từ thử nghiệm đơn vị và/hoặc tích hợp. Hơn nữa, JaCoCo có tích hợp Jenkins tốt. Đây là một ví dụ mà JaCoCo sử dụng các bài kiểm tra đơn vị chắc chắn và kiểm tra tích hợp không thành công.
<build>
<plugins>
<!-- Unit tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
</plugin>
<!-- Integration tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.16</version>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<!--
The JaCoCo plugin generates a report about the test coverage. In contrast to the cobertura plugin
JaCoCo can be configured to generate code coverage for integration tests. Another advantage of JaCoCo
is that it reports only, cobertura executes all unit tests again (beside the surefire plugin).
-->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.4.201312101107</version>
<executions>
<execution>
<id>jacoco-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-prepare-agent-integration</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
</execution>
<execution>
<id>jacoco-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>jacoco-integration</id>
<goals>
<goal>report-integration</goal>
</goals>
</execution>
<execution>
<id>jacoco-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules />
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
nơi bạn đã đặt các bài kiểm tra tích hợp của mình (ví dụ: src/it/java hoặc src/test/java) và cách thử thực hiện các bài kiểm tra? –
Làm thế nào để bạn chạy CNTT của bạn? Sử dụng một mô-đun riêng biệt? Sử dụng maven-failsafe-plugin? Trong một hồ sơ riêng biệt? –