我正在尝试从命令行运行 JUnit 测试用例
我遵循的代码设置为 bin dir
c:/eclipse/workspace/sample/bin> java -cp C:\Ram Doc\eclipse\plugins\org.junit_4.8.2.v4_8_2_v20110321-1705.junit.jar C:\Ram Doc\eclipse\workspace\Script_Bvt\bin org.junit.runner.JUnitCore login_sanity(That's my class Name)
错误信息是
C:\Ram Doc\eclipse\workspace\Script_Bvt\bin>java -cp C:\Ram Doc\eclipse\plugins\
org.junit_4.8.2.v4_8_2_v20110321-1705.junit.jar java org.junit.runner.JUnitCore
login_sanity
Exception in thread "main" java.lang.NoClassDefFoundError: Doc\eclipse\plugins\o
rg/junit_4/8/2/v4_8_2_v20110321-1705/junit/jar
Caused by: java.lang.ClassNotFoundException: Doc\eclipse\plugins\org.junit_4.8.2
.v4_8_2_v20110321-1705.junit.jar
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: Doc\eclipse\plugins\org.junit_4.8.2.v4_8_2_v20110
321-1705.junit.jar. Program will exit.
如果我将其保留login_sanity
在其他位置并执行:
C:\Selenium>javac -cp "C:\Selenium\junit4.10\junit4.10\junit-4.10.jar;." org.junit.runner.JUnitCore login_sanity
我收到以下错误:
Class names, 'org.junit.runner.JUnitCore,login_sanity', are only accepted if
annotation processing is explicitly requested
以下显示了我的完整步骤: