0
JMockit可以修改它模拟的方法的参数吗?修改它所嘲讽的方法的返回值肯定很容易,但如何修改参数本身呢?我知道有可能至少使用验证来捕获和测试模拟参数,但是这是在事实发生之后发生的。JMockit:修改模拟方法的参数
这里是我的简化代码:
class Employee{
Integer id;
String department;
String status;
//getters and setters follow
}
我想的方法测试:
public int createNewEmployee() {
Employee employee = new Employee();
employee.setDepartment("...");
employee.setStatus("...");
//I want to mock employeeDao, but the real DAO assigns an ID to employee on save
employeeDao.saveToDatabase(employee);
return employee.getId(); //throws NullPointerException if mocked, because id is null
}
这是一个强大的功能。 – user64141