快捷键 command+shift+T 将光标放在需要测试的类名上
方式一:
测试类上添加注解
@RunWith(SpringRunner.class)
@SpringBootTest(classes = 启动类.class)
测试方法添加注解@Test
注意 import的包是
import org.junit.Test;
方式二:
测试类上不用加注解
测试类继承一个抽象测试启动类,在启动类中指定主启动类入口。(包括一些其他配置等)
测试方法加@Test注意 import的包是
import org.junit.jupiter.api.Test;