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

私は必要なものに到達するためにantを使用することになりました。このブログに感謝します: http://blog.varunin.com/2010/03/ant-script-for-generating-junit-report.html#comment-form

すべてのテスト イベントの詳細なレポートを取得する場合は、これを使用してください。

于 2012-12-14T00:22:14.940 に答える
0

Mavenサイトからの参照として

Surefire-report:reportテスト結果レポートを HTML 形式で生成します。 Surefire-report:report-onlyこの目標はテストを実行せず、レポートを作成するだけです。

レポートのみを試しています。もう1つのレポートを目標として試してください

于 2012-12-13T05:03:44.273 に答える