JUnit4 插件和 Eclipse 中 junit.jar 的构建路径

发布于 2024-11-02 07:59:26 字数 557 浏览 8 评论 0原文

我已经安装了 Eclipse (Helios) 以及 JUnit3、JUnit4 和 Java 开发工具插件,用于一些 Android 开发。

我创建了一些单元测试,但它们运行的​​唯一方法(不为 org.junit.Test 抛出 java.lang.ClassNotFoundException)是添加外部 JAR到我正常安装的 JUnit 中的 junit.jar 测试项目构建路径。

为什么 Eclipse 无法引用 JUnit4 插件中的 junit.jar(当我在 Package Explorer 中展开库时可以看到该插件)?事实上,我可以从测试项目中删除 JUnit4 库,只留下外部 JAR,并且测试运行良好。

我尝试将插件文件夹的路径添加到 CLASSPATH 系统环境变量中,因为我必须设置 JUnit,但这没有什么区别。插件路径在 Eclipse 中创建为 JUNIT_HOME 类路径变量,但这被标记为已弃用。

我是否还需要 JUnit3 和 JUnit4 插件,因为这些插件必须随我使用的发行版一起提供?

I've got Eclipse (Helios) installed along with the JUnit3, JUnit4 and Java Development Tools plug-ins for some Android development.

I've created some unit tests but the only way they run (without throwing a java.lang.ClassNotFoundException for org.junit.Test) is if I add an External JAR to the test project build path for junit.jar from the normal JUnit install I have.

Why isn't Eclipse able to reference the junit.jar from the JUnit4 plugin which I can see when I expand the library in Package Explorer? In fact I can remove the JUnit4 Library from the test project leaving just the External JAR and the tests run fine.

I tried adding the path to the plug-in folder to my CLASSPATH system environment variable as I had to setting up JUnit but this made no difference. The plugin path is created as a JUNIT_HOME Classpath Variable in Eclipse but this is labeled as deprecated.

Do I even need the JUnit3 and JUnit4 plugins as these must have come with the distro I used?

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

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

发布评论

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

评论(1

无所的.畏惧 2024-11-09 07:59:26

在任何新项目中,添加所需的 Junit deps(在 Maven 中声明它们的例外)的可靠方法是使用内置的 Junit 测试创建测试捷径。

转到新建> Junit 测试用例。如果正确的 deps 不在项目类路径中,eclipse 会自动将它们拉入。

In any new project, the sure way I add the required Junit deps (with the exception of declaring them in maven) is through creating the test using the in-built Junit test shortcut.

Go to New > Junit Test Case. If the right deps are not on the project classpath, eclipse will pull them in automatically.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文