spring整合junit抽离重复部分

/**
 * 业务层测试
 * spring整合junit抽离重复部分
 * 		ApplicationContext ac = new AnnotationConfigApplicationContext(factory.class);
		ICustomerService cs = (ICustomerService) ac.getBean("customerService");
 * 第一步导入spring-test-4.3.2.RELEASE
 * 
 * 第二步使用@RunWith,把原有的main函数替换掉换成spring提供的
 * 			要更换的类名:SpringJunit4ClassRunner
 * 第三部使用spring提供的注解告知spring,配置文件或者注解类所在的位置--->             
 * @ContextConfiguration
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={factory.class})
public class test {
	@Autowired
	private ICustomerService cs;
	@Test
	public void findall(){
		List<Customer> list = cs.findAllCustomer();
		for(Object o : list){
			System.out.println(o);
		}
	}
	
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值