pom.xml:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.3.17.RELEASE</version>
<scope>test</scope>
</dependency>
测试类:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring-config.xml")
public class TestSprintTest {
@Autowired
private SuperMan sm;//要测试的对象,自动完成对象的创建和装配
@Autowired
private ApplicationContext factory;
@Autowired
private A a;
@Test
public void testSuperMan(){
sm.fly();
}
@Test
public void testA(){
a.testA();
}
}