我能够在 Eclipse 中完美地运行 testng。但是,我想使用命令行(Win 8)运行它,如不同论坛上所述。这是我正在尝试解决错误的不同方法-
1.
java -cp "D:\testng\testng-6.8.7.jar" org.testng.TestNG testng.xml
Exception in thread "main" java.lang.NoClassDefFoundError: com/beust/jcommander/
ParameterException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.beust.jcommander.ParameterExcep
tion
at java.net.URLClassLoader$1.run(Unknown Source)
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)
... 6 more
2. java -cp "D:\testng\testng-6.8.7.jar:{$PATH_TILL_HERE}\target\test-classes\org\test\automation\links\LinksTest.cl
ass" org.testng.TestNG testng.xml
Error: Could not find or load main class org.testng.TestNG
感谢您的任何指示。