我有一个Maven Surefire报告,它生成3个文件:
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的TESTS-TestSuites.xml输出文件只显示JUNit中的信息,因此根本没有显示故障信息(尽管我的*.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>还是,我这样做是错误的,并能确保火本身产生一份合适的报告?
发布于 2013-08-21 21:54:30
我解决了。我现在没有使用maven-antrun-plugin,我现在使用的是maven-surefire-report插件,以及目标站点maven-surefire:report。注意:您需要首先运行站点目标,以便为报告生成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>https://stackoverflow.com/questions/18365686
复制相似问题