Mockito Features and Best Practices
summary
Shows concrete how-to and limits: uses an Astro gateway/service example that calls api.open‑notify.org/astros.json, parses records and groups astronauts by craft to illustrate when to isolate with mocks vs run an integration test. Demonstrates creating mocks, stubs and spying on existing classes (logger example), warns do not mock types you don't own, and explains Mockito core + JUnit extension, argument matchers, verify/verifyInOrder, and that mocking static methods now in core (inline mock maker moved into Mockito 5). Code is at kousen/mockito-book.
AI-written summary · about
chapters (11)
- 0:00Introduction and speaker background
- 1:15Why use Mockito and its purpose
- 6:54Problem illustration with Astro API
- 14:17Mocks vs stubs and their differences
- 23:25Mockito API and BDD alternatives
- 30:28Mockito annotations and injection
- 37:05Mockito versions and compatibility
- 43:04Argument matchers and custom matchers
- 51:10Verification and interaction order
- 54:20Testing best practices and limitations
- 57:09Summary and closing remarks
related talks
59mJava Testing Part 2: Mocks, Stubs, and Spies with Mockito 4
31mBeyond the Mockery- Why We Should Embrace Testing Without Mocking Frameworks
30mMocks, Stubs, and Spies, Oh My
37mBeyond the Mockery: Why We Should Embrace Testing Without Mocking Frameworks
36mMocks, Stubs, and Spies, Oh My!
31mGreat tools for engineers: even cleaner tests with Mockito 2
27mDe-mock your tests
01h 01mMastering Java Testing With JUnit, Mockito, and AssertJ in IntelliJ IDEA
