spring boot 1.3集成测试

注明:Spring boot 1.3集成测试

1.pom.xml 添加依赖包

<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;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;

@RunWith(SpringJUnit4ClassRunner.class)
//SpringBootApplication.class 为boot启动类
@SpringApplicationConfiguration(SpringBootApplication.class)
@WebAppConfiguration
public class SpringBootApplicationTests {

    @Test
    public void testGetValue(){

    }
}

3.其他业务测试类 可以继承SpringBootApplicationTests,注入要测试的类,测试其中的方法,使用assert断言测试其中的方法

参考-- https://blog.csdn.net/oppo840817/article/details/80075856

猜你喜欢

转载自blog.csdn.net/onlyoneggp/article/details/88219817