[java]代码库
package cn.outofmemory.easymock;
public class UserServiceImplTest extends Assert {
@Test
public void testQuery() {
User expectedUser = new User();
user.set.;
UserDao userDao = Easymock.createMock(UserDao.class);
Easymock.expect(userDao.getById("1001")).andReturn(expectedUser);
Easymock.replay(userDao);
UserServiceImpl service = new UserServiceImpl();
service.setUserDao(userDao);
user user = service.query("1001");
assertNotNull(user);
assertEquals(); //veify return user
Easymock.verify(userDao);
}
}
//源代码片段来自云代码http://yuncode.net