开发者

Running JUnit from command prompt: classpath confusion

开发者 https://www.devze.com 2023-03-09 20:34 出处:网络
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 fol

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 containing p.
  • The argument to JUnitCore is the fully qualified name of the class, i.e. p.hw not p/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

0

精彩评论

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