1. 程式人生 > >spring 框架測試

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)