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 { }

猜你喜欢

转载自blog.csdn.net/peng_0129/article/details/85005686