如何从命令行运行 TestNG
2022-09-01 04:25:56
如何从命令行运行.java TestNG 项目?
我已经通读了TestNG文档,并尝试了以下方法,但无济于事:
C:\projectfred> java org.testng.TestNG testng.xml
...在我的项目中使用以下测试.xml文件:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="SuiteAll" verbose="1">
<test name="TestAll">
<packages>
<package name="com.project.fred.tests"/>
</packages>
</test>
</suite>
我得到的错误是这样的:
Exception in thread "main" java.lang.NoClassDefFoundError: org/testng/TestNG
Caused by: java.lang.ClassNotFoundException: org.testng.TestNG
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: org.testng.TestNG. Program will exit.
显然,我没有在命令行中正确引用TestNG。有谁知道如何让它工作?