简体   繁体   中英

Testng FileNotFoundException when running from command line

I am getting Testng FileNotFoundException when running from command line, following is the command line parameters i am using

java -cp MyTestAutomation-06252019.jar org.testng.TestNG ZaleniumMiniRegression.xml

Following is the stack-trace :

[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)

Assuming that you set up your classes properly in the XML file, you can try this:

Extract to a folder called TestNG on the C:\\ directory

Set the classpath environment (TestNG folder and your Project folder)

Change directory (cd) into your project folder and then write these commands:

set classpath=C:\eclipse-2018\Tests\bin;C:\TestNG\plugins\*

java -classpath %classpath% org.testng.TestNG ZaleniumMiniRegression.xml

That's it.

If you've made a runnable jar file with a main method you could simply do:

java -jar <Your runnable jar file>.jar

If you run into trouble getting the webdriver to run from the command line, check my answer here: https://stackoverflow.com/a/60172758/1843452

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM