Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
DealPresenterTestV3 - TP article
public class DealPresenterTest {
@Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
@Rule public ToothPickRule toothPickRule = new ToothPickRule(this, “DealPresenter”);
@Mock DealUtil dealUtil;
@Mock DealApiClient dealApiClient;
@Mock WishlistManager wishlistManager;
@Inject DealPresenter dealPresenterUnderTest;
@Before
public void setUp() {
toothPickRule.inject(this);
}
...
@Test
public void onWishlistSelected_when_wishlistEnabled() throws Exception {
//GIVEN
Deal deal = new Deal();
deal.id = "12345";
dealPresenterUnderTest.deal = deal;
when(dealUtil.isWishlistEnabled(deal)).thenReturn(true);
//WHEN
dealPresenterUnderTest.onWishlistSelected();
//THEN
verify(wishlistManager).addDealToWishlist(deal.id);
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment