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

浙公网安备 33010602011771号