Java JUnit Eclipse 插件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1962567/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 01:50:54  来源:igfitidea点击:

JUnit Eclipse Plugin?

javaeclipseidejunitplugins

提问by Nick Heiner

I feel stupid for not being able to find this, but where is the JUnit plugin for Eclipse? I've included the latest .jarin my buildpath, but I still don't have the option to create a new test case, run test cases with the green/red bar, etc. I need the plugin for this, right?

找不到这个我觉得很愚蠢,但是 Eclipse 的 JUnit 插件在哪里?我已经.jar在我的构建路径中包含了最新的,但我仍然没有选择创建一个新的测试用例,运行带有绿色/红色条的测试用例等等。我需要这个插件,对吧?

EDIT:I'm using "Eclipse for PHP Developers". So perhaps that wouldn't include JUnit automatically. Do I have to download Eclipse again, or can I just get that functionality somehow?

编辑:我正在使用“Eclipse for PHP Developers”。所以也许这不会自动包含 JUnit。我是否必须再次下载 Eclipse,或者我可以以某种方式获得该功能?

采纳答案by Pascal Thivent

JUnit is part of Eclipse Java Development Tools(JDT). So, either install the JDT via Software Updatesor download and install Eclipse IDE for Java Developers(actually, I'd recommend installing Eclipse IDE for Java EE Developersif you want a complete built-in environment for server side development).

JUnit 是Eclipse Java 开发工具(JDT) 的一部分。因此,要么通过软件更新安装 JDT,要么为 Java 开发人员下载并安装Eclipse IDE(实际上,如果您想要一个完整的服务器端开发内置环境,我建议为 Java EE 开发人员安装Eclipse IDE)。

You add it to a project by right clicking the project in the Package Explorer and selecting Build Path -> Add Libraries...Then simply select JUnit and click Next >.

您可以通过在 Package Explorer 中右键单击项目并选择Build Path -> Add Libraries...将其添加到项目中,然后只需选择 JUnit 并单击Next >

回答by aubreyrhodes

Junit is included by default with Eclipse (at least the Java EE version I'm sure). You may just need to add the view to your perspective.

Junit 默认包含在 Eclipse 中(我确定至少是 Java EE 版本)。您可能只需要将视图添加到您的透视图中。

回答by BalusC

It's built in Eclipse since ages. Which Eclipse version are you using? How were you trying to create a new JUnit test case? It should be File> New> Other> Java - JUnit - JUnit Test Case(you can eventually enter Filter text "junit").

它自古以来就内置于 Eclipse 中。您使用的是哪个 Eclipse 版本?你是如何尝试创建一个新的 JUnit 测试用例的?它应该是File> New> Other> Java - JUnit - JUnit Test Case(您最终可以输入过滤器文本“junit”)。

回答by anthonator

Eclipse has built in JUnit functionality. Open your Run Configuration manager to create a test to run. You can also create JUnit Test Cases/Suites from New->Other.

Eclipse 内置了 JUnit 功能。打开您的运行配置管理器以创建要运行的测试。您还可以从 New->Other 创建 JUnit 测试用例/套件。

回答by Fabian Steeg

You should be able to add the Java Development Tools by selecting 'Help'-> 'Install New Software', there you select the 'Juno'update site, then 'Programming Languages'-> 'Eclipse Java Development Tools'.

您应该能够通过选择“帮助”-> “安装新软件”来添加 Java 开发工具,然后选择“Juno”更新站点,然后选择“编程语言”-> “Eclipse Java 开发工具”

After that, you will be able to run your JUnit tests with 'Right Click'-> 'Run as'-> 'JUnit test'.

之后,您将能够使用'Right Click'-> 'Run as'-> 'JUnit test'运行JUnit 测试

回答by Ladlestein



Maybe you're in the wrong perspective?

也许你的观点错误?

Eclipse has a construct called a "perspective"; it's a task-oriented arrangement of windows, toolbar buttons, and menus. There's a Java perspective, a Debug perspective, there's probably a PHP perspective, etc. If you're not in the Java perspective, you won't see some of the buttons you expect (like New Class).

Eclipse 有一个称为“透视”的构造;它是面向任务的窗口、工具栏按钮和菜单的排列。有 Java 透视图、Debug 透视图、可能还有 PHP 透视图等。如果您不在 Java 透视图中,您将看不到一些您期望的按钮(例如 New Class)。

To switch perspectives, see the long-ish buttons on the right side of the toolbar, or use the Window menu.

要切换视角,请查看工具栏右侧的长按钮,或使用“窗口”菜单。

回答by Ashish

You do not need to install or update any software for the JUnit. it is the part of Java Development tools and comes with almost most of the latest versions in Eclipse.

您不需要为 JUnit 安装或更新任何软件。它是 Java 开发工具的一部分,几乎随 Eclipse 中的大多数最新版本一起提供。

Go to your project. Right click onto that->Select buildpath->add library->select JUnit from the list ->select the version you want to work with-> done

转到您的项目。右键单击那个-> 选择构建路径-> 添加库-> 从列表中选择 JUnit -> 选择要使用的版本-> 完成

build you project again to see the errors gone:)

再次构建您的项目以查看错误消失:)

回答by paranza

You might want to try out Quick JUnit: https://marketplace.eclipse.org/content/quick-junit

您可能想尝试 Quick JUnit:https: //marketplace.eclipse.org/content/quick-junit

The plugin is stable and it allows switching between production and test code. I am currently using Eclipse Mars 4.5 and the plugin is supported for this release as well as for the following:

该插件是稳定的,它允许在生产和测试代码之间切换。我目前使用 Eclipse Mars 4.5,此版本以及以下版本支持该插件:

Luna (4.4), Kepler (4.3), Juno (4.2, 3.8), Previous to Juno (<=4.1)

Luna (4.4), Kepler (4.3), Juno (4.2, 3.8), 在 Juno 之前 (<=4.1)