熟悉Java但不熟悉IntelliJ,如何“开始”JUnit集成?
灵感来自于Looking for a tutorial on using JUnit with Intellij IDEA 9.x,它没有回答我的问题,并且是为旧版本的IntelliJ设计的。
发布于 2013-10-13 16:56:20
基本上,你只需要在类路径上使用junit.jar --这里有一个快速的方法:
test)标记为测试根。public class MyClassTest { @Test public void testSomething() {}}
@Test批注将被标记为错误(红色),请按f2导航到该批注。
好了,你的任务完成了!右键单击您的测试并选择Run 'MyClassTest‘来运行它并查看测试结果。
Maven备注:或者,如果您使用的是maven,则可以在步骤4中选择选项Add Maven Dependency...,转到Search for artifact窗格,输入junit并采用任何版本(例如4.8或4.9)。
发布于 2013-10-12 13:19:34
”
测试导入org.junit.Assert;导入org.junit.Test;公有类MyFirstTest { @Test public void firstTest() { Assert.assertTrue(true);}}
发布于 2015-05-22 00:44:53
在我将我的项目与jar文件链接之后,我需要启用JUnit插件。
要启用JUnit插件,请转到文件->设置,在搜索栏中键入"JUnit“,然后在”插件“下选中"JUnit”。
vikingsteve's advice above可能会正确链接这些库。否则,打开文件->项目结构,转到库,按加号,然后浏览到
C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 14.1.1\lib\并添加以下jar文件:
hamcrest-core-1.3.jar
junit-4.11.jar
junit.jar https://stackoverflow.com/questions/19330832
复制相似问题