Great tools for engineers: even cleaner tests with Mockito 2
summary
Mockito 2 (released Oct 2016 with ~50 contributors) adds an opt‑in strict stubbing mode via a JUnit rule that surfaces argument mismatches early, turns unused stubs into test failures, and removes the need to duplicate verifyNoMoreInteractions. Demo shows better failure locations for stubbing bugs, byte‑buddy replacing CGLIB for mocking, built‑in Android support, Java 8 lambda friendliness, and support for mocking finals. Claim: fewer brittle, over‑specified tests and faster debugging on large Java codebases (author estimates ~2M users).
AI-written summary · about
chapters (11)
- 0:00Introduction to Mockito
- 1:06Mockito usage and history
- 2:25Community and philosophy
- 4:52Test driven development
- 6:57Debugging in Mockito 1
- 11:07Emulating strict mocks
- 17:03Mockito's lenient approach
- 20:38Strict stubbing feature
- 23:58Dry tests with strict stubs
- 26:25Unnecessary stub detection
- 28:13Future and conclusion
related talks
31mBeyond the Mockery- Why We Should Embrace Testing Without Mocking Frameworks
33mLearnt Lessons from Mockito 2.x Migration
59mJava Testing Part 2: Mocks, Stubs, and Spies with Mockito 4
27mDe-mock your tests
46mModern Testing Tools for Java Developers
57mModern Testing Tools for Java Developers
37mBeyond the Mockery: Why We Should Embrace Testing Without Mocking Frameworks
40mMockito 2 - Powrót Króla
