junit测试Dao层
来源:互联网 发布:linux开源中国 编辑:程序博客网 时间:2024/04/28 01:15
通过junit测试spring框架构建下的Dao层示例:
package com.project.dao;import java.text.DateFormat;import java.text.SimpleDateFormat;import java.util.Date;import org.junit.Assert;import org.junit.Test;import org.junit.runner.RunWith;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.test.context.ContextConfiguration;import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;@RunWith(SpringJUnit4ClassRunner.class)// 不能是PowerMock等别的class,否则无法识别spring的配置文件@ContextConfiguration("file:conf/applicationContext.xml")// 读取spring配置文件public class userDAOTest {@Autowired//检索applicationContext.xml,自动注入指定的beanUserDAO userDAO;@Testpublic void testGetUser() {int userId = 1;String nickname = "昵称1";Assert.assertEquals(userId, userDAO.getUser( userId ).getUserId());Assert.assertEquals(nickname, userDAO.getUser( userId ).getNickname());}}
0 0
- junit测试Dao层
- junit 测试持久层 dao Service
- 使用JUnit测试SSH框架的Service层和DAO层
- 使用JUnit测试SSH框架的Service层和DAO层
- 用JUnit测试SSH框架的Service层和DAO层
- ssh框架Junit测试DAO
- Junit 测试 Service 层
- JUNIT测试Hibernate和Spring的Dao层方法出现的问题
- ssh 下dao 层测试
- Spring+hibernate+junit的Dao测试
- Spring Junit测试Dao和Service
- 使用junit测试ssh中的dao
- SpringMVC+Spring+hibernate+junit的Dao测试
- junit4 测试dao层 和service层
- Junit测试service层和control层
- Junit结合Spring对Dao层进行单元测试
- Junit结合Spring对Dao层进行单元测试
- java使用jUnit,jMockit,dbunit做DAO层单元测试方法
- 企业模式之Unit Of Work模式
- java创建API,通过document生成xml返回给外部
- android6.0以后调用相机和选取图片
- 工作单元模式(UnitOfWork)学习总结
- Spring 配置多数据源实现数据库读写分离
- junit测试Dao层
- (转)MVC中的Repository模式
- 锚点链接
- Myeclipse下配置SVN报错问题 svn: E175002: java.lang.RuntimeException: Could not generate DH keypair
- VM
- SOAP服务参数校验方案
- 用powermock mock Dao Http请求 log4j
- Linux_Shell 服务状态 校验脚本
- 大数据题的解法总结