I wrote the test which uses BBDMockito and Argument Captor:
@Test
public void loadNoItemFromRepository_showsMissingItem() {
//given
itemDetailPresenter = new ItemDetailPresenter(UNCHECKED_ITEM.getId(), itemsRepository, itemDetailView);
given(itemDetailView.isActive()).willReturn(true);
//when
itemDetailPresenter.load();
verify(itemsRepository).getItem(eq(UNCHECKED_ITEM.getId()), getItemCallbackArgumentCaptor.capture());
getItemCallbackArgumentCaptor.getValue().onDataNotAvailable();
//then
then(itemDetailView).should().showMissingItem();
}
Verify placed in //when section is confusing because the name suggests it should be placed in the verification section (//then). Is there an alias for verify() so I can use it with argument captor and the name will be more appropriate for //when?
Aucun commentaire:
Enregistrer un commentaire