How to run test case in JUnit from command line ?
I'm trying to run a JUnit test case from command line using this command:
F:\>java org.junit.runner.JUnitCore org.junit4.9b2.junit.SimpleTest
but I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/junit/runner/JUnitCore
Caused by: java.lang.ClassNotFoundException: org.junit.runner.JUnitCore
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.junit.runner.JUnitCore. Prog开发者_开发技巧ram will exit.
What is the problem?
Obviously you need junit on the classpath :-)
java -cp path/to/junit.jar:path/to/local/classes org.junit.runner.JUnitCore \
org.junit4.9b2.junit.SimpleTest
(replace the :
with ;
on windows platforms)
精彩评论