【发布时间】:2020-01-20 09:48:46
【问题描述】:
从命令行运行时,我得到了 Testng FileNotFoundException,以下是我正在使用的命令行参数
java -cp MyTestAutomation-06252019.jar org.testng.TestNG ZaleniumMiniRegression.xml
以下是堆栈跟踪:
[SuiteHTMLReporter] [ERROR] test-output\testng.css (The system cannot find the path specified)
java.io.FileNotFoundException: test-output\testng.css (The system cannot find the path specified)
at java.base/java.io.FileOutputStream.open0(Native Method)
at java.base/java.io.FileOutputStream.open(FileOutputStream.java:292)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:235)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:185)
at org.testng.internal.Utils.writeResourceToFile(Utils.java:263)
at org.testng.reporters.HtmlHelper.generateStylesheet(HtmlHelper.java:32)
at org.testng.reporters.SuiteHTMLReporter.generateReport(SuiteHTMLReporter.java:55)
at org.testng.TestNG.generateReports(TestNG.java:1062)
at org.testng.TestNG.run(TestNG.java:1005)
at org.testng.TestNG.privateMain(TestNG.java:1326)
at org.testng.TestNG.main(TestNG.java:1294)
【问题讨论】:
-
请出示您的代码。
-
test-output\testng.css是相对路径。它被搜索到您当前的工作目录中,这是您启动java命令的位置。如果test-output\testng.css文件不存在,您将收到该错误。 -
@Aaron test-output\ 是 testNG 自己创建的文件夹,我不知道它为什么要查看那个位置。
-
您是否在任何地方指定了该路径,还是 testNG 的默认路径?如果你自己在某个地方指定了它,我会检查它是否在重写为
test-ouput/testng.css时效果更好。否则我还要检查启动java命令的用户是否真的可以写入这个目录 -
@Aaron ,不,我没有指定输出路径。对当前目录的写入没有限制。