测试前设置TestNG的输出目录 [英] Set output directory of TestNG before test
本文介绍了测试前设置TestNG的输出目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用XML文件(右键单击,以TestNG套件运行)在Eclipse上运行一些TestNG测试.我仅将maven用于依赖项,而不用于运行测试.有没有办法在代码中设置输出目录?
I am running some TestNG tests with Eclipse, using XML files (right click, run as TestNG suite). I use maven only for dependencies, not for running tests. Is there a way to set the output directory in the code?
例如
System.out.println(ctx.getOutputDirectory());
打印当前输出目录,默认情况下为test-output.但是为什么没有setOutputDirectory?我想将@BeforeTest方法中的输出目录设置为我在testng.xml文件中设置的文件夹.
prints the current output directory, which by default, is test-output. But why isn't there a setOutputDirectory? I would like to set the output directory in the @BeforeTest method to a folder that I set in the testng.xml file.
推荐答案
找到了答案.
@BeforeTest
public void setup(ITestContext ctx) {
TestRunner runner = (TestRunner) ctx;
runner.setOutputDirectory("/Path/To/Store/Output");
}
这篇关于测试前设置TestNG的输出目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文