Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mockito 2022-01-25

sullis
January 25, 2022

Mockito 2022-01-25

Unit testing with Mockito
Portland Java User Group
January 25, 2022

#java
#mockito

sullis

January 25, 2022
Tweet

More Decks by sullis

Other Decks in Programming

Transcript

  1. We wrote unit tests to verify: • happy path •

    edge case scenarios • error handling logic
  2. • inventory reservation • payment system • shipping cost calculator

    • shipping restrictions • purchase limit service • tax calculator • discount calculator Gilt.com Checkout was dependent upon:
  3. We setup mock objects for: • Payment authorization • Inventory

    reservation • Discount redemption • Tax calculation • Shipping calculation
  4. OrderManager unit test OrderManager manager = new OrderManager( taxEngine, shippingCalc);

    manager.sync(order); manager.submit(order); verify(taxEngine, once()).calculate(any()); assertTrue(order.isSubmitted());