0
JMockit이 조롱 한 메소드의 매개 변수를 수정할 수 있습니까? 모의 메소드의 반환 값을 수정하는 것이 확실하지만 매개 변수 자체를 수정하는 방법은 무엇입니까? 적어도 Verification을 사용하여 조롱 된 매개 변수를 캡처하고 테스트 할 수는 있지만이 사실이 발생한 후에 발생합니다.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