- 程序中有Junit环境.
- 导入一个jar包.spring与junit整合jar包.
- spring-test-3.2.0.RELEASE.jar
- 测试代码:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")
public class HelloServiceTest {
@Autowired
private HelloService helloService;
@Test
public void demo1 () {
helloService.sayHello();
}
}
这种方式下会运行整个周期,包括销毁的生命阶段