我正在尝试通过 maven surefire 插件为 TestNG 使用自定义报告程序。我已经有一个自定义监听器,它似乎被选中了。但是,看起来根本没有使用自定义报告程序:
<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>
知道为什么会这样吗?
最佳答案
我想通了。看起来以下内容根本不起作用:
<property>
<name>reporter</name>
<value>com.mystuff.test.MyEmailableReporter</value>
</property>
尽管有相反的文件。在 TestNG
类中似乎有一个名为 TestNG#addListener(IReporter listener)
的方法,与其名称相反,它接受实现 IReporter< 的报告
。 Maven Surefire (v2.12.1) 调用此方法来添加监听器和报告。但是,它不会在名称为 reporter
的属性下查找报告。相反,您必须将自定义报告程序添加到 listener
属性:
<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 - 将自定义记者与 maven surefire 插件一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11835790/