SpringJunit4测试
前段时间工作中遇到了,所以就简单学习了一下,只学到了点皮毛,
1.测试类
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
public class SpringJunit4test
{
@Resource
Date date;
@Test
public void testas()
{
System.out.println(date.getTime());
}
@Autowired
ApplicationContext ctx;
@Test
public void testbb() throws Exception
{
DaoBean db = ctx.getBean(DaoBean.class);
db.show();
}
}
2.DaoBean
3.XML配置