Mockito is a Java mocking framework that creates test doubles for a class's dependencies, letting you test a unit of code in isolation from the real implementations it collaborates with.
Instead of hitting a real payment API in a unit test, you mock the PaymentClient so charge() always returns a controlled success or failure response.
A concise interview answer is
Mockito is a mocking framework that lets me replace a class's real dependencies with configurable fake objects, so I can test business logic in isolation without touching databases, networks, or other slow external systems. It's central to writing fast, deterministic unit tests.
Last updated: 16 July 2026
Next question: How do you mock an object in Mockito?