找不到类:org.junit.tests.AllTests - OSX

发布于 2024-09-16 18:21:25 字数 386 浏览 7 评论 0原文

我在开始使用 JUnit 测试时遇到了一些麻烦。这应该是非常基本的。我从 JUnit.org 下载了 junit-4.8.2.jar 并将其放在我的主目录中。

如果我尝试使用以下命令在 TCSH 终端中测试我的设置:

java -cp ~/junit-4.8.2.jar org.junit.runner.JUnitCore org.junit.tests.AllTests

我收到以下输出

JUnit version 4.8.2
Could not find class: org.junit.tests.AllTests

Time: 0.003

OK (0 tests)

任何帮助将不胜感激。谢谢。

I'm having a little trouble getting started with JUnit tests. This should be pretty basic. I downloaded junit-4.8.2.jar from JUnit.org and placed it in my home directory.

If I try to test my setup in a TCSH terminal with the following command:

java -cp ~/junit-4.8.2.jar org.junit.runner.JUnitCore org.junit.tests.AllTests

I receive the following output

JUnit version 4.8.2
Could not find class: org.junit.tests.AllTests

Time: 0.003

OK (0 tests)

Any help would be greatly appreciated. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

滴情不沾 2024-09-23 18:21:25

查看:junit 常见问题解答 特别是此项目,将我的项目加粗:

通过运行随 JUnit 分发的示例测试来测试安装。 请注意,示例测试直接位于安装目录中,而不是 junit.jar 文件中。因此,请确保 JUnit 安装目录位于您的 CLASSPATH 中。然后只需输入:

java org.junit.runner.JUnitCore org.junit.tests.AllTests

如果您只下载了 jar,则无法运行示例测试。您需要获取 src 包并按照说明进行操作。

Check out: the junit faq specifically this item, bolding mine:

Test the installation by running the sample tests distributed with JUnit. Note that the sample tests are located in the installation directory directly, not the junit.jar file. Therefore, make sure that the JUnit installation directory is on your CLASSPATH. Then simply type:

java org.junit.runner.JUnitCore org.junit.tests.AllTests

If you only downloaded the jar you can't run the sample tests. You need to get the src package and follow the instructions for that.

肩上的翅膀 2024-09-23 18:21:25

这是由 unixking 发布的 -
http://sourceforge.net/projects/junit/files 获取最新版本的 JUnit /junit/4.10/

将junit4.10.zip解压到C:\MyDev\lib,所以我们有C:\MyDev\lib\junit4.10

在命令提示符下,运行以下命令

: the home is where i work best
set MY_HOME=C:/MyDev

: place to find the junit jar files
set JUNIT_HOME=%MY_HOME%/lib/junit4.10

: find the junit jar files as well as other classes that one intends to use
set CLASSPATH=%CLASSPATH%;%JUNIT_HOME%;%JUNIT_HOME%/junit-4.10.jar

: this is where my jdk is
set JAVA_HOME=%MY_HOME%/tool/jdk1.6.0_24

: run sample tests (sitting in any folder)
java org.junit.runner.JUnitCore org.junit.tests.AllTests 

This was posted by unixking -
Get the latest version of JUnit from http://sourceforge.net/projects/junit/files/junit/4.10/

Unzip junit4.10.zip at C:\MyDev\lib, so we have C:\MyDev\lib\junit4.10

In the command prompt, run the following commands

: the home is where i work best
set MY_HOME=C:/MyDev

: place to find the junit jar files
set JUNIT_HOME=%MY_HOME%/lib/junit4.10

: find the junit jar files as well as other classes that one intends to use
set CLASSPATH=%CLASSPATH%;%JUNIT_HOME%;%JUNIT_HOME%/junit-4.10.jar

: this is where my jdk is
set JAVA_HOME=%MY_HOME%/tool/jdk1.6.0_24

: run sample tests (sitting in any folder)
java org.junit.runner.JUnitCore org.junit.tests.AllTests 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文