1.在pom.xml下添加Junit依赖: <!--添加junit环境的jar包--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> 2.创建测试类: /** * Created by Administrator on 2019/…
集成JUnit测试 既然使用了Spring,那么怎么集成到JUnit中进行测试呢,首先大家能够想到的肯定是: public class TestMain { @Test public void test(){ ApplicationContext context = new AnnotationConfigApplicationContext(TestConfiguration.class); TestService service = context.getBean(TestService.c…