spring boot单元测试

使用springboot写单元测试

1.添加依赖

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>1.5.6.RELEASE</version>
<scope>test</scope>
</dependency>
版本可以任意选择

2.添加注解

@SpringBootTest()
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = XqaWebApplication.class)

SpringbootTest注解完成类的加载等功能

ContextConfiguration注解用来配置上下文

 

posted @ 2019-03-20 11:32  炒鸡  阅读(291)  评论(0)    收藏  举报