我在测试来自 DAO 的检查用户方法时遇到问题。这是代码:
private UserService service;
private UserDao mockDAO;
@Before
public void setUp(){
service=new UserService();
mockDAO=createMock(UserDao.class);
service.setUserDao(mockDAO);
}
@Test
public void testCheckUserLogin(){
User results=new User();
User test=new User();
test.setUsername("x");
test.setPass("y");
EasyMock.expect(mockDAO.checkUser(test)).andReturn(results.getIdUser());
EasyMock.replay(mockDAO);
assertEquals(service.login(test),service.login(results));
EasyMock.verify(mockDAO);
}
当我运行它时,我收到此错误:
java.lang.AssertionError:
Unexpected method call UserDao.checkUser(com.sot.car.model.User@4e527622):
我不知道为什么我会收到这个错误?我EasyMock.expect
为方法检查用户添加了