普通测试

依赖:

<!--spring单元测试依赖 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${springframework}5.0.11</version>
<scope>test</scope>
</dependency>
5.0.11

 

@RunWith(SpringJUnit4ClassRunner.class) //配置文件的位置 //若当前配置文件名=当前测试类名-context.xml 就可以在当前目录中查找@ContextConfiguration() @ContextConfiguration("classpath:resource/applicationContext.xml")

springboot测试

依赖

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

 

@SpringBootTest
@RunWith(SpringRunner.class)

posted on 2018-12-30 21:21  mljqqh  阅读(83)  评论(0编辑  收藏  举报