我喜欢使用 Maven 更改 ReportNG 标准报告的样式(使用不同于 reportng.css 的其他 .css)。我的 pom.xlm 看起来像这样
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter,org.testng.reporters.EmailableReporter</value> </property>
</properties>
<systemProperties>
<property>
<name>org.uncommons.reportng.title</name>
<value>My own titel in Test Report</value>
</property>
<property>
<name>org.uncommons.reportng.stylesheet</name>
<value>${project.basedir}/src/report/resources/MyTestReport.css</value>
</property>
</systemProperties>
...
我可以更改标题,但是当我尝试对 systemproperty org.uncommons.reportng.stylesheet 执行相同操作时,我只会得到默认报告。有人遇到过同样的问题吗?您是如何解决的?
最诚挚的问候 安妮卡
最佳答案
我以为我遇到了同样的问题,因为我希望看到我指定的嵌入在所有页面上的 CSS 文件。
相反,ReportNG 似乎从您指定的 css 中获取样式(上面示例中的 MyTestReport.css),并将其放入嵌入在所有页面上的生成的 custom.css 文件中。
检查 **/surefire-reports/html/custom.css。您的样式应该在那里(假设 CSS 的路径正确)。
关于maven-surefire-plugin 和 ReportNG 无法更改测试报告的样式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14256153/