1.junit资源下载
- 我这里使用的是IDEA2018.2.8版本,使用的junit-4.10.jar。
- junit-4.10.jar下载链接
链接:https://pan.baidu.com/s/1LN18YKLSd1UxB0ihZO6sAw
提取码:umio
2.IDEA中如何添加junit包
- 在IDEA中选择File-Project Structure(或直接使用快捷键ctrl+alt+shift+s打开),点击最右边的+号,选择jars or directories。
- 在这里找到自己的jar包路径点击OK即可。
3.基本使用代码
- 测试的类中导入junit包,类名一般是以Test开头。在类中写的方法之前加上“@Test"即可,IDEA中运行这块的代码即可。
import org.junit.Test;
public class TestJunit {
@Test
public void test(){
System.out.println("junit test");//输出:unit test
}
}