Java 科贝图拉和码头
当我在Jetty上使用cobertura运行我的Web应用程序时,我正在尝试获取覆盖率报告。 我们已经使用surefire插件运行了cobertura进行单元测试。 我们还为运行集成测试配置了故障保护插件 我已经(手动)装备并部署了我的战争 当使用integration tests only概要文件运行Java 科贝图拉和码头,java,maven,integration-testing,code-coverage,cobertura,Java,Maven,Integration Testing,Code Coverage,Cobertura,当我在Jetty上使用cobertura运行我的Web应用程序时,我正在尝试获取覆盖率报告。 我们已经使用surefire插件运行了cobertura进行单元测试。 我们还为运行集成测试配置了故障保护插件 我已经(手动)装备并部署了我的战争 当使用integration tests only概要文件运行mvn verify时,似乎cobertura正在工作,因为我在eclipse控制台中收到了各种新的警告(我从那里运行jetty),可能是因为字节码被cobertura更改了。 但是我无法写入.s
mvn verify
时,似乎cobertura正在工作,因为我在eclipse控制台中收到了各种新的警告(我从那里运行jetty),可能是因为字节码被cobertura更改了。
但是我无法写入.ser
文件,即使在jetty服务器上调用“stop”
在运行mvn cobertura:cobertura
时,我确实会得到一个.ser
文件,并在我的webapp的目标/站点
目录下生成一个报告。报告显示0%的覆盖率,因为cobertura:cobertura
不运行任何测试
如何使用故障保护使cobertura正常工作来运行集成测试?
还有其他建议吗
谢谢,
Ben也许您需要一些
标签来配置cobertura maven插件。
上面有一些例子,但这个答案看起来更好:我通过使用插件解决了这个问题。它扩展了原来的cobertura插件,并允许使用仅报告目标。此外,我必须运行两个单独的命令(见下文)来测试和生成报告(合并到1个命令不起作用)。这是我的插件配置
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-it-maven-plugin</artifactId>
<version>2.5</version>
<configuration>
<formats>
<format>html</format>
</formats>
<check>
<haltOnFailure>false</haltOnFailure>
</check>
</configuration>
<executions>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.4.2.v20110526</version>
<configuration>
<stopKey>aaaaaaaaaaaaa</stopKey>
<stopPort>8085</stopPort>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
<classesDirectory>target/generated-classes/cobertura</classesDirectory>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>net.sourceforge.cobertura</groupId>
<artifactId>cobertura</artifactId>
<version>1.9.4.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
最后,我使用mvn站点
生成报告。这是我的报告配置
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<!-- An error on version 2.8 -->
<version>2.7</version>
<configuration>
<reportsDirectories>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<reportsDirectory>${project.build.directory}/failsafe-reports</reportsDirectory>
</reportsDirectories>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>report-only</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.1</version>
<configuration>
<!-- An error that takes long time to generate this report -->
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>dependencies</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-it-maven-plugin</artifactId>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>report-only</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
org.apache.maven.plugins
maven surefire报告插件
2.7
${project.build.directory}/surefire报告
${project.build.directory}/failsafe报告
仅报告
org.apache.maven.plugins
maven项目信息报告插件
2.1
假的
依赖关系
org.codehaus.mojo
cobertura it maven插件
html
xml
仅报告
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<!-- An error on version 2.8 -->
<version>2.7</version>
<configuration>
<reportsDirectories>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<reportsDirectory>${project.build.directory}/failsafe-reports</reportsDirectory>
</reportsDirectories>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>report-only</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.1</version>
<configuration>
<!-- An error that takes long time to generate this report -->
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>dependencies</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-it-maven-plugin</artifactId>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>report-only</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>