[英]JUnit run tests command line
I've got the following structure 我有以下结构
lib/junit-4.10.jar
tests/Tester.java
tests/Tester.class
build/jar/jar_file.jar
(Tester belongs to package tests) (测试人员属于包裹测试)
I can compile tests using 我可以使用编译测试
javac -cp build/jar/jar_file.jar:lib/junit-4.10.jar tests/*.java
However I can't seem to run tests: 但是我似乎无法运行测试:
java -cp build/jar/jar_file.jar:lib/junit-4.10.jar org.junit.runner.JUnitCore tests.Tester
or 要么
java -cp build/jar/jar_file.jar:lib/junit-4.10.jar org.junit.runner.JUnitCore Tester
And I get the following output: 我得到以下输出:
JUnit version 4.10
Could not find class: tests.Tester
Time: 0.001
OK (0 tests)
How do I resolve this Could not find class
problem? 如何解决此问题Could not find class
问题? I think it may be classpath related. 我认为它可能与类路径有关。
Assuming this is Linux/Mac (not Windows) and your path separator is correct (:), since your test class files exist in package subdirectories under the current working directory (.) You need to add "." 假设这是Linux / Mac(不是Windows)并且您的路径分隔符是正确的(:),因为您的测试类文件存在于当前工作目录(。)下的包子目录中。您需要添加“。” to your class path, for example: 到您的类路径,例如:
java -cp .:build/jar/jar_file.jar:lib/junit-4.10.jar org.junit.runner.JUnitCore tests.Tester
The classpath should be semi colon separated (on Windows - not sure what you are using.) 类路径应该是半冒号分隔的(在Windows上 - 不确定您使用的是什么。)
java -cp build/jar/jar_file.jar;lib/junit-4.10.jar org.junit.runner.JUnitCore tests.Tester
Also with this command line you will need to run it in your project root 此命令行还需要在项目根目录中运行它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.