首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >maven-antrun-plugin能生成显示异常错误的HTML报告吗?

maven-antrun-plugin能生成显示异常错误的HTML报告吗?
EN

Stack Overflow用户
提问于 2013-08-21 19:09:01
回答 1查看 1.2K关注 0票数 0

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

代码语言:javascript
复制
   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文件中的一个错误,如下所示:

代码语言:javascript
复制
<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配置:

代码语言:javascript
复制
<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>

还是,我这样做是错误的,并能确保火本身产生一份合适的报告?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-21 21:54:30

我解决了。我现在没有使用maven-antrun-plugin,我现在使用的是maven-surefire-report插件,以及目标站点maven-surefire:report。注意:您需要首先运行站点目标,以便为报告生成CSS文件。

代码语言:javascript
复制
    <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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18365686

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档