【发布时间】:2011-02-26 07:12:39
【问题描述】:
是否可以从测试内部写一些东西到 surefire-reports/MyClass.txt ?任何类型的记录器等? TestNG中有一个记者:
Reporter.log("Something here");
并且消息出现在报告中的测试方法下。 JUnit中是否有类似的东西
【问题讨论】:
标签: maven-2 junit maven surefire
是否可以从测试内部写一些东西到 surefire-reports/MyClass.txt ?任何类型的记录器等? TestNG中有一个记者:
Reporter.log("Something here");
并且消息出现在报告中的测试方法下。 JUnit中是否有类似的东西
【问题讨论】:
标签: maven-2 junit maven surefire
在 Eclipse 或通过 Hudson 运行时,我很幸运地在 junit 中使用了这种设置的 log4j。这可能不适用于您正在使用的测试/运行器/IDE 的组合,因为这对我来说并非在所有情况下都有效。您可能需要调整 forkMode。您还必须对路径进行硬编码。
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>never</forkMode>
<systemProperties>
<property>
<name>log4j.configuration</name>
<value>file:src/test/resources/log4j.xml</value>
</property>
</systemProperties>
</configuration>
</plugin>
另一个可能是使用redirectTestOutputToFile 将标准输出转储到安全报告文件中。没有用过,所以不知道这是否对你有用。
【讨论】: