从Eclipse项目的命令行中运行JUnit 4(Running JUnit 4 from comm

2019-10-18 09:56发布

我现在有ClasspathSuite设置运行我所有的JUnit测试。 我正在试图让ClasspathSuite类从命令行运行。 当我在bin目录并运行此命令:

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)

我也试图与该文件的绝对路径运行相同的命令,导致相同的错误消息。 我究竟做错了什么?

Answer 1:

刚脱下.class部分。 Java的知道要查找该文件时,您所指定的类名。

java -cp /usr/share/java/junit.jar org.junit.runner.JUnitCore MySuite


文章来源: Running JUnit 4 from command line on Eclipse project