Using custom reporters with the maven surefire plugin

懵懂的女人 提交于 2019-12-01 12:34:44

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>

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>

Not very intuitive.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!