Mockito
Mockito is a Java mocking framework for creating and configuring test doubles and specifying or verifying their behavior and interactions.
Quarkus in Action
Mockito is a Java mocking framework for creating test doubles and specifying their behavior dynamically.
- How it is used
- Isolates Quarkus application tests from costly, unavailable, slow, or remote collaborators.
- How deep it goes
- Explains dynamic mock creation, configured behavior, CDI installation, scope limits, and native-mode constraints.
- Examples
- Uses a mocked GraphQLInventoryClient that returns one Peugeot during an availability-and-reservation test.
- What you can do after
- Apply it via QuarkusMock and Mockito DSL to isolate collaborators while testing application behavior.
Testing Spring Boot Applications
Mockito is a Java mocking framework for creating configurable test doubles and verifying interactions with them.
- How it is used
- Isolates tests from complex business logic and external dependencies by supplying configurable fake objects and interaction checks.
- How deep it goes
- Defines configurable fakes, stubbing, and verification, but does not detail Mockito APIs or implementation internals.
- Examples
- Uses widgetService.count() returning 5 and verifies one emailService.sendEmail() call with user@example.com.
- What you can do after
- Apply via Mockito by replacing dependencies, defining return values, and verifying calls in isolated tests.
Read how Testing Spring Boot Applications explains Mockito →
Spring Start Here, Second Edition
Mockito is a Java mocking framework for creating configurable test doubles and verifying their interactions.
- How it is used
- Isolates Java unit tests from dependencies by replacing collaborators with controllable mocks.
- How deep it goes
- Demonstrates mock creation, stubbing, interaction verification, annotations, and exception-flow checks without detailing framework internals.
- Examples
- Tests money transfers and login outcomes, including repository calls and missing-account exceptions.
- What you can do after
- Apply it via mock(), given(), and verify() to control collaborators and check tested-method interactions.
Read how Spring Start Here, Second Edition explains Mockito →
Kafka for Architects
Mockito is a Java mocking framework for creating and configuring test doubles that substitute for real dependencies.
- How it is used
- Isolates Kafka-backed services during lightweight unit tests by replacing networked producers and consumers with mock dependencies.
- How deep it goes
- Defines mock substitution and behavioral verification, but stops short of detailed Mockito APIs or implementation walkthroughs.
- Examples
- Uses ProfileService, Customer360Service, mocked Kafka components, return values, producer calls, and downstream side effects.
- What you can do after
- Apply via Mockito to test Kafka-backed service behavior without a Kafka cluster or real network communication.
Also covered in
- Clean Applications with Hexagonal ArchitectureIn early access (MEAP)
- Kafka Streams in Action, Second Edition
Related concepts
- mocking frameworkkind of · A mocking framework is a software toolkit for creating and configuring test doubles that simulate dependencies and allow their interactions to be controlled or verified.
- test doubleproduces · A test double is a substitute for a real dependency or collaborator that provides controlled behavior or enables interaction observation during testing.
- mockingproduces · Mocking is a testing technique that replaces a dependency or collaborator with a controlled substitute to simulate behavior, isolate code, or inspect interactions.
- ArgumentCaptorused by · ArgumentCaptor is a Mockito utility that captures arguments passed to a method so tests can inspect them.
- MockitoExtensionused by · MockitoExtension is a JUnit Jupiter extension that integrates Mockito with test execution, including mock creation and lifecycle management.
Questions about Mockito
What is Mockito?
Mockito is a Java mocking framework for creating and configuring test doubles and specifying or verifying their behavior and interactions.
Which Manning books explain Mockito?
Quarkus in Action, Testing Spring Boot Applications, Spring Start Here, Second Edition and Kafka for Architects.
What is Mockito a kind of?
Mockito is a kind of mocking framework. A mocking framework is a software toolkit for creating and configuring test doubles that simulate dependencies and allow their interactions to be controlled or verified.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.



