开发者

How to run test case in JUnit from command line ?

开发者 https://www.devze.com 2023-02-14 14:51 出处:网络
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

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)

0

精彩评论

暂无评论...
验证码 换一张
取 消