![](/img/trans.png)
[英]BeforeGroups method is not executed when running testng tests by maven
[英]change the console output when running testng tests via maven
我正在使用mvn test
或mvn test -Dtest=<Class-Name>
或mvn test -Dgroups=<groups...>
通过maven运行TestNG测试。
我想存储在文件中的测试有很多输出,但是我需要的控制台输出是:
TestA.test1-通过
TestA.test2-失败
TestB.test11-通过
我实现了一个实现ITestListener的侦听器,并将System.out.println(message); 每种方法都有合适的消息。 在pom.xml中,我添加了一个插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<configuration>
<properties>
<property>
<name>listener</name>
<value><my listener full name class></value>
</property>
</properties>
</configuration>
</plugin>
但是似乎没有任何响应,并且相同的输出不断进入控制台。
知道我在做什么错吗? 我想继续通过mvn test
运行我的测试,但是将输出更改为更有条理。
如果您希望该侦听器为每个测试工作,那么您将错误地导入了测试类。 您的pom.xml应该是这样的:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter
</value>
</property>
</properties>
</configuration>
</plugin>
您应该禁用默认侦听器以使用自定义侦听器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.