编写一个Junit的测试类,代码一切正常,运行时报错,原因是因为idea未自动导入junit的包。需要自己手工导入。

package com.mashensoft;


import org.junit.Before;
import org.junit.Test;

public class UtilTest {

    @Before
    public void setUp() throws Exception {
    }

    @Test
    public void add() {
        System.out.println(123);
    }

    @Test
    public void add1() {
    }
}

在这里插入图片描述
打开菜单File=>Project Structure
在这里插入图片描述
选择Libraries=>点+号
在这里插入图片描述
弹出对话框,选择Java
在这里插入图片描述
找到idea的安装目录lib下,选择junit的jar包
在这里插入图片描述
选择指定的的module
在这里插入图片描述
添加完毕
在这里插入图片描述
可以运行junit代码
在这里插入图片描述

Logo

一站式 AI 云服务平台

更多推荐