Viv*_*ath 2 testng surefire maven
我正在尝试使用带有 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>
Run Code Online (Sandbox Code Playgroud)
知道为什么会这样吗?
我想通了。看起来以下内容根本不起作用:
<property>
<name>reporter</name>
<value>com.mystuff.test.MyEmailableReporter</value>
</property>
Run Code Online (Sandbox Code Playgroud)
尽管有相反的文件。在TestNG类中,似乎有一个名为 的方法TestNG#addListener(IReporter listener),与其名称相反,它接受一个实现 的报告IReporter。Maven Surefire (v2.12.1) 调用这个方法来添加监听器和报告。但是,它不会在具有 name 的属性下查找报告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>
Run Code Online (Sandbox Code Playgroud)
不是很直观。
| 归档时间: |
|
| 查看次数: |
3541 次 |
| 最近记录: |