添加依赖
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
启动类模块下创建测试类的目录
创建TestMain测试类,注意:包名要和main里的包名一致
测试类添加@springbootTest注解,和RunWith注解
@SpringBootTest
@RunWith(SpringRunner.class)
public class TestMain {
@Autowired
private ISysRoleService roleService;
@Test
public void test() throws FileNotFoundException {
roleService.deleteRoleById(1L);
}
}