public void createId() {
Customer cust = findCustomer(this.custId);
Address addr = findAddress(this.addr);
UniqueIdCreator create = new UniqueIdCreator(this.custId, this.addr, this.name);
create.populate();
this.name.setName(create.customerName.getName());
}
для выше как я пропускаю метод create.populate();
Mockito пропустить новый объект вызова
Вот что я сделал:
@Test
public void test {
Customer cust = new Customer();
cust.setId(1);
cust.setName("test");
Address addr = new Address();
addr.setStreet("test-st");
IdCreator c = Mockito.spy(new IdCreator(cust,addr,null));
getDao.getPresist.add(cust);
getDao.getPresist.add(addr);
c.createId();
}
ошибка: пустой указатель внутри метода «create.populate() ;»
Это только для mockito.
Возможный дубликат [Как высмеять конструктор по умолчанию с помощью PowerMock с помощью Mockito?] (Http://stackoverflow.com/questions/15501572/how-to-mock-the-default-constructor-using-powermock- с-mockito) – talex
Макет-конструктор, а затем метод вызова метода. – talex
Я пробовал это, но, похоже, он все еще не пропускает. Я пробовал метод mock b, затем называть b, ничего не делая. но tc.methodA все еще читает b – logger