【发布时间】:2014-08-04 14:15:30
【问题描述】:
我在测试用例中使用以下代码得到类转换异常。
Employee employee1= new Employee();
Employee employee2= new Employee();
Employee employee3= new Employee();
int id=1234;
when(employee1.getID()).thenReturn(id);
when(employee2.getID()).thenReturn(id);
when(employee3.getID()).thenReturn(id);
我想把它概括为
when((((Employee)Matchers.any(Employee.class)).getID())).thenReturn(id);
我做错了什么吗?
java.lang.ClassCastException: org.hamcrest.core.IsInstanceOf cannot be cast to com.site.model.Employee
【问题讨论】: