1. 程式人生 > >SpringBootTest單元測試實戰

SpringBootTest單元測試實戰

1、引入相關依賴
             <!--springboot程式測試依賴,如果是自動建立專案預設新增-->
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-test</artifactId>
                    <scope>test</scope>
                </dependency>


        2、使用
            @RunWith(SpringRunner.class)  //底層用junit  SpringJUnit4ClassRunner
            @SpringBootTest(classes={XdclassApplication.class})//啟動整個springboot工程
            public class SpringBootTests { }