SpringBoot 单元测试

SpringBoot 单元测试

依赖注入

引入依赖:

 <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-test</artifactId>
           <scope>test</scope>
</dependency>

  

这里引入了一个spring-boot-starter-test依赖,是springboot中写单测所需要的。
在单元测试类上添加@RunWith(SpringRunner.class)@SpringBootTest注解:

 

posted @ 2020-07-13 17:33  谢世林  阅读(173)  评论(0)    收藏  举报