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