Running JUnit 4 from command line on Eclipse project

好久不见. 提交于 2019-12-11 04:48:57

问题


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

I get:

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?


回答1:


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


来源:https://stackoverflow.com/questions/17846365/running-junit-4-from-command-line-on-eclipse-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!