Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/138.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从命令提示符运行JUnit:类路径混乱_Junit_Classpath - Fatal编程技术网

从命令提示符运行JUnit:类路径混乱

从命令提示符运行JUnit:类路径混乱,junit,classpath,Junit,Classpath,从一个正常工作的JUnit命令行调用到稍微复杂一点的调用,我遇到了麻烦。一开始,“hw”是一个没有指定包的类。从hw.class所在的目录中成功执行以下命令: 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 我现在为hw指定一个包“p”,将hw.java移动到subdi

从一个正常工作的JUnit命令行调用到稍微复杂一点的调用,我遇到了麻烦。一开始,“hw”是一个没有指定包的类。从hw.class所在的目录中成功执行以下命令:

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
我现在为hw指定一个包“p”,将hw.java移动到subdir“p”中,然后重新编译。如何修改上述命令以成功测试该类?我一直这么想

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

将从p的“superdir”起作用,但它不…。

您的命令有两个问题:

  • 类路径必须包括位于包层次结构根目录的目录,即不是
    p
    ,而是包含
    p
    的目录
  • JUnitCore的参数是类的完全限定名,即
    p.hw
    not
    p/hw

在项目的类路径中执行测试时,类丢失 s 解决方案:加入你的pom 公地发现 公地发现 0.5 测验