步骤1:在项目工程pom.xml引入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
步骤2:新建测试目录 test>java, 把目录设为Test Source Root
步骤3:选择需要进行测试的类,选中类名然后按住option+enter(Mac版本)如果是windows:alt+enter
步骤4:选择需要测试的方法
步骤5:在测试类上面添加注解:
@RunWith(SpringRunner.class)
@SpringBootTest
注意导入org.junit.Test
包