一、SpringBoot整合JUnit
步骤1:添加整合junit起步依赖(可以直接勾选)
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope>
</dependency>
步骤2:编写测试类,注入测试类
@SpringBootTest
class SpringbootApplicationTests {@Autowiredprivate BookService bookService;@Testpublic void testSave() {bookService.save();}
}
测试通过: