| Version 2 (modified by chenyang, 14 years ago) (diff) |
|---|
单元测试应用示例——测试DAO层对象
cn.com.pcgames.gamehall2.repository.impl.GameDAOImpl是GameDAO实现类,完成Game对象在数据库中增删改查的功能.
我们在DAO层使用了Spring JdbcTemplate封装了DAO操作,我们使用Spring测试框架辅助编写单写单元测试,可以简化测化,我们让测试类去继承AbstractTransactionalJUnit4SpringContextTests
/**
* GameDAO测试
* @author ChenYang
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:applicationContext.xml"})
public class GameDAOImplTest extends AbstractTransactionalJUnit4SpringContextTests{
......
}
![(please configure the [header_logo] section in trac.ini)](http://www1.pconline.com.cn/hr/2009/global/images/logo.gif)