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