这是我的EmployeeServiceTest.java
@RunWith(JMockit.class)
public class EmployeeServiceTest {
@Tested
private EmployeeServiceImpl employeeService;
@Injectable
private EmployeeDaoImpl employeeDao;
@Test
public void testGetEmployee() {
Employee employee= new Employee();
employee.setAddress("Test Address");
new Expectations() {
{
employeeDao.get(Employee.class, 1L);result = employee;
}
};
Employee employee1 = employeeService.getEmployee(1L);
System.out.println(employee1.getAddress()); // Line 1
}
}
这是我的EmployeeServiceImpl
。java
public class EmployeeServiceImpl implements EmployeeService {
@Autowired
private EmployeeDao employeeDao;
public Employee getEmployee(Long id) {
return employeeDao.get(Employee.class, id);
}
}
问题是当我在System.out.println(employee.getAddress())
line no1
时,我将地址设为空而不是Test Address
。我不确定是什么
问题在这里?