【问题标题】:Can maven-antrun-plugin generate a HTML report showing the exception errors?maven-antrun-plugin 可以生成显示异常错误的 HTML 报告吗?
【发布时间】:2013-08-21 19:09:01
【问题描述】:

我有一个生成 3 个文件的 Maven Surefire 报告:

   TESTS-TestSuites.xml  - shows only passing tests. no info about fails or errors.
   TEST-me.qa.MyTest.xml - see below
   me.qa.MyTest.txt - file containing console output showing exceptions

每个失败的测试都会在 TEST-me.qa.MyTest.xml 文件中显示一个错误,如下所示:

<testcase name="testIPcheckCanCalculate" classname="me.qa.TestLogChecks" time="0.016">
    <failure message="Average is too low: 0.5357142857142857. Min: 20.0" 
       type="java.lang.AssertionError">java.lang.AssertionError: Average is too low:
         0.5357142857142857. Min: 20.0
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.assertTrue(Assert.java:41)
    at me.qa.TestLogChecks.testIPcheckCanCalculate(TestLogChecks.java:230)
</failure>
    <system-out>Testing InPreparer.getInv().getSomething().checkCanCalculate() ...
</system-out>
  </testcase>

maven-antrun-plugin 能否生成显示异常错误(和失败)的 HTML 报告?目前,名为 junit-noframes.html 的 JUNit 输出文件仅在 TESTS-TestSuites.xml 中显示信息,因此根本没有显示任何失败信息(即使我的包含是针对 *. xml)。我的解决方法是也查看 me.qa.MyTest.txt 文件以查看错误是什么,但我希望这些错误出现在我的报告中,并显示失败的测试总数报告。

这是我的 Maven 配置:

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
        <executions>
            <execution>
                <id>test-reports</id>
        <phase>test</phase>
        <configuration>
                <tasks>
                    <junitreport todir="target/surefire-reports">
                        <fileset dir="target/surefire-reports">
                          <include name="**/*.xml" />
                        </fileset>
                        <report format="frames" todir="target/surefire-reports" />
                    </junitreport>
        </tasks>
        </configuration>
    <goals>
        <goal>run</goal>
        </goals>
    </execution>
</executions>
<dependencies>
    <dependency>
        <groupId>ant</groupId>
    <artifactId>ant-junit</artifactId>
    <version>1.6.5</version>
    </dependency>
        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant-trax</artifactId>
            <version>1.8.0</version>
        </dependency>
</dependencies>
</plugin>

或者,我做错了,Surefire 本身可以生成合适的报告吗?

【问题讨论】:

    标签: maven surefire maven-antrun-plugin


    【解决方案1】:

    我解决了。我现在不使用 maven-antrun-plugin,而是使用 maven-surefire-report 插件以及目标 site maven-surefire:report 。注意:您需要先运行 site 目标才能为报告生成 CSS 文件。

        <reporting>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-report-plugin</artifactId>
                    <version>2.16</version>
                    <configuration>
                        <showSuccess>false</showSuccess>
                        <outputDirectory>${basedir}/target/surefire-reports</outputDirectory>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>2.1</version>
                    <configuration>
                        <outputDirectory>${basedir}/target/surefire-reports</outputDirectory>
                    </configuration>
                </plugin>
            </plugins>
        </reporting>
    
    </project>
    

    【讨论】:

      猜你喜欢
      • 2015-06-19
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 2020-05-28
      • 1970-01-01
      • 2010-09-18
      • 2017-10-10
      • 1970-01-01
      相关资源
      最近更新 更多