【发布时间】: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