在Eclipse项目上从命令行运行JUnit 4 [英] Running JUnit 4 from command line on Eclipse project
本文介绍了在Eclipse项目上从命令行运行JUnit 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前已经设置了ClasspathSuite来运行我的所有JUnit测试.我正在尝试让ClasspathSuite类从命令行运行.当我在bin目录中并运行以下命令时:
I currently have ClasspathSuite set up to run all of my JUnit tests. I'm working on trying to get the ClasspathSuite class to run from the command line. When I am in the bin directory and run this command:
java -cp /usr/share/java/junit.jar org.junit.runner.JUnitCore MySuite.class
我得到:
JUnit version 4.10
Could not find class: MySuite.class
Time: 0.002
OK (0 tests)
我还尝试使用相同的命令运行文件的绝对路径,导致出现相同的错误消息.我在做什么错了?
I also tried running the same command with the absolute path to the file, resulting in the same error message. What am I doing wrong?
推荐答案
只需卸下.class
部分.指定类名后,Java便知道要在该文件中查找.
Just take off the .class
part. Java knows to look in that file when you specify the class name.
java -cp /usr/share/java/junit.jar org.junit.runner.JUnitCore MySuite
这篇关于在Eclipse项目上从命令行运行JUnit 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文