2016-10-03 117 views
1

我们使用Maven 3.0.5,Surefire 2.7.1和TestNG 5.10运行TestNG测试。使用Maven禁用TestNG的HTML报告

我们希望禁用在target/surefire-reports/Command line suite下创建的HTML报告的生成,后者目录是TestNG套件名称。我们认为是TestNG的记者创建了一份报告,但尽管有以下配置,报告仍然无法禁用。

<plugin> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <version>2.7.1</version> 
    <configuration> 
     <properties> 
      <property> 
       <name>usedefaultlisteners</name> 
       <value>false</value> 
      </property> 
     </properties> 
    </configuration> 
</plugin> 

有没有办法关闭HTML报告?每次测试都需要花费很多时间。

+0

您可以尝试将TestNG升级到5.14.9或更新版本(如最新的5.14.10或6.8)?或者,升级到Surefire插件的2.19.1版本。 – Tunaki

+0

我已经用TestNG 5.14.10和Surefire 2.19.1在同一次运行中升级了它,但没有帮助。 – nolexa

+0

嗯,我刚刚尝试了TestNG 6.9.8和5.14.10与Surefire 2.19.1和您的文章中的配置工作,因为在没有HTML报告创建。你确定这个配置不在''部分吗? – Tunaki

回答

1

TestNG和Surefire的这些版本存在一个错误,使得侦听程序无法正常工作。从Using Custom Listeners and Reporters的神火文档中:

不受支持的版本: - TestNG的5.14.1和5.14.2:由于内部TestNG的问题,听众和记者不与TestNG的工作。请将TestNG升级至5.14.9或更高版本。注意:它可能会在未来的绝对版本中修复。

这可能会影响5.10一样,所以你需要升级到TestNG的较新版本。虽然它,你也可以Maven的Surefire插件升级到当前最新的,这是2.19.1:

<dependency> 
    <groupId>org.testng</groupId> 
    <artifactId>testng</artifactId> 
    <version>6.9.8</version> <!-- or 5.14.10 for the latest in 5.x branch --> 
    <scope>test</scope> 
</dependency> 

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <version>2.19.1</version> 
    <configuration> 
    <properties> 
     <property> 
     <name>usedefaultlisteners</name> 
     <value>false</value> 
     </property> 
    </properties> 
    </configuration> 
</plugin> 

是否值得并称这将禁用从作为HTML报告由TestNG生成,但Surefire本身仍然会生成XML报告。您可以使用Surefire配置中的disableXmlReport参数禁用该参数。