1

我想使用 maven 的surefire-report 插件生成一份报告,它将为我提供所有测试的详细报告,其中包含在每次测试运行期间记录的日志事件,而不仅仅是我的测试失败的事件。这也将为我提供测试失败的完整背景。

这是我的 pom.xml 文件:

        <artifactId>SampleTests</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>sampleTests</name>
<url>http://maven.apache.org</url>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>2.11</version>
        <type>maven-plugin</type>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20090211</version>
    </dependency>
</dependencies> 
<build>
    <sourceDirectory>src/main/java</sourceDirectory>
    <outputDirectory>${basedir}/target/classes</outputDirectory>
    <testSourceDirectory>src/main/test</testSourceDirectory>
    <testOutputDirectory>${basedir}/target/test-classes</testOutputDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.4.2</version>
        <configuration>
          <includes>
            <include>com/mypackage/**</include>
          </includes>
          <test>**/*Tests</test>
        </configuration>
      </plugin>
      <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
        </plugin>
    </plugins>
</build>
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>2.6</version>
        <reportSets>
          <reportSet>
            <reports>
              <report>report-only</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>
</project>

我使用 mvn surefire-report:report 在这里生成报告。所以我想知道我是否可以做任何额外的事情,以便查看测试运行期间发生的情况的详细报告?

4

2 回答 2

0

作为来自Maven 网站的参考

surefire-report:report将测试结果报告生成为 HTML 格式。 surefire-report:report-only这个目标不运行测试,它只构建报告。

您正在尝试仅报告。尝试将另一份报告作为目标

于 2012-12-13T05:03:44.273 回答
0

I ended up using ant to get to what I needed. Thanks to this blog: http://blog.varunin.com/2010/03/ant-script-for-generating-junit-report.html#comment-form

If you want to get a detailed report of all the test events then please use this

于 2012-12-14T00:22:14.940 回答