将自定义报告程序与Maven surefire插件一起使用 [英] Using custom reporters with the maven surefire plugin

查看:94
本文介绍了将自定义报告程序与Maven surefire插件一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用带有Maven surefire插件的TestNG自定义报告程序.我已经有一个自定义的侦听器,并且似乎可以接听了.但是,看起来根本没有使用自定义报告程序:

I'm trying to use a custom reporter for TestNG with the maven surefire plugin. I already have a custom listener and that seems to get picked up. However, it doesn't look like the custom reporter is being used at all:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <testFailureIgnore>false</testFailureIgnore>
        <properties>
            <property>
                <name>listener</name>
                <value>com.mystuff.test.TestNGListener</value>
            </property>
            <property>
                <name>reporter</name>
                <value>com.mystuff.test.MyEmailableReporter</value>
            </property>
        </properties>
    </configuration>
</plugin>

知道为什么会这样吗?

推荐答案

我知道了.看起来以下内容根本不起作用:

I figured this out. It looked like the following doesn't work at all:

<property>
    <name>reporter</name>
    <value>com.mystuff.test.MyEmailableReporter</value>
</property>

尽管有相反的文档说明.在TestNG类中,似乎有一个名为TestNG#addListener(IReporter listener)的方法,与它的名称相反,它接受实现IReporter的报告. Maven Surefire(v2.12.1)调用此方法来添加侦听器和报告.但是,它不会在名称为reporter的属性下查找报告.相反,您必须将自定义报告程序添加到listener属性:

in spite of documentation to the contrary. In the TestNG class it appears that there is a method called TestNG#addListener(IReporter listener), which contrary to its name, accepts a report which implements IReporter. Maven Surefire (v2.12.1) calls this method to add listeners and reports. However, it doesn't look for reports under a property with name reporter. Instead, you have to add your custom reporter to the listener property:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <testFailureIgnore>false</testFailureIgnore>
        <properties>
            <property>
                <name>listener</name>
                <value>com.mystuff.test.TestNGListener,com.mystuff.test.MyEmailableReporter</value>
            </property>
        </properties>
    </configuration>
</plugin>

不是很直观.

这篇关于将自定义报告程序与Maven surefire插件一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆