Spring Boot超簡單的測試類demo
阿新 • • 發佈:2021-10-15
Spring Boot結合Junit的簡單測試類demo
1.引入依賴
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency>
2.編寫測試類
import org.junit.Test; import org.junit.runner.RunWith;TRANSLATE with x English TRANSLATE with EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Backimport org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @SpringBootTest @RunWith(SpringRunner.class) public class ApplicationTests { @Test public void contextLoads() { System.out.println("--------------------------------------------------"); } }