spring 框架测试

普通测试

依赖:

<!--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)

猜你喜欢

转载自www.cnblogs.com/mljqqh/p/10200743.html