我究竟如何从命令行运行 .java TestNG 项目?
我已通读 TestNG 文档,并尝试以下方法无济于事:
C:\projectfred> java org.testng.TestNG testng.xml
...在我的项目中使用以下 testng.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。有谁知道如何让这个工作?