Running JUnit from command prompt: classpath confusion
I'm having trouble getting from a working JUnit command line invocation to something only slightly more complicated. At the outset, 'hw' is 开发者_高级运维a class with no package specified. The following command is successfully executed from the dir in which hw.class lives:
java -cp /usr/share/java/hamcrest-core.jar:/usr/lib/eclipse/plugins/org.junit4_4.5.0.v20090824/junit.jar:./ org.junit.runner.JUnitCore hw
I now specify a package 'p' for hw, move hw.java into subdir 'p', and recompile. How can I modify the above command to have the class successfully tested? I've have thought that
java -cp /usr/share/java/hamcrest-core.jar:/usr/lib/eclipse/plugins/org.junit4_4.5.0.v20090824/junit.jar:p org.junit.runner.JUnitCore p/hw
would work from the 'superdir' of p, but it doesn't...
There are two problems with your command:
- The classpath must include the directory that is at the root of the package hierarchy, i.e. not
p
but the directory containingp
. - The argument to JUnitCore is the fully qualified name of the class, i.e.
p.hw
notp/hw
The classes are missed at the time of execution of test in classpath of the project s Solution : add in your pom commons-discovery commons-discovery 0.5 test
精彩评论