# mockito/mockito

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/mockito-mockito).**

15,432 stars · 2,656 forks · Java · MIT

## Links

- GitHub: https://github.com/mockito/mockito
- Homepage: http://mockito.org
- awesome-repositories: https://awesome-repositories.com/repository/mockito-mockito.md

## Description

Mockito is a Java mocking framework and JUnit testing library used to create simulated objects and stub method calls to isolate components during unit tests. It functions as a dynamic proxy generator and bytecode instrumentation tool, allowing for the creation of runtime substitutes that mimic the behavior of real classes.

The framework distinguishes itself by providing the ability to mock final classes and methods, bypassing standard language restrictions through bytecode modification. This capability enables the testing of legacy code that lacks interfaces.

The toolset covers behavioral mocking to define specific method responses and interaction verification to ensure methods were called with the correct arguments. It provides mechanisms for mock object generation and the recording of method interaction history for post-execution verification.

## Tags

### Testing & Quality Assurance

- [Unit Testing Frameworks](https://awesome-repositories.com/f/testing-quality-assurance/unit-testing-frameworks.md) — Serves as a primary library for creating simulated objects to isolate Java code units during testing.
- [Mock Interaction Recorders](https://awesome-repositories.com/f/testing-quality-assurance/automation-interaction-tools/test-automation-tools/test-recording-tools/mock-interaction-recorders.md) — Captures detailed records of method invocations on mocks for post-execution interaction verification. ([source](https://github.com/mockito/mockito/wiki/What%27s-new-in-Mockito-2))
- [Mocking Frameworks](https://awesome-repositories.com/f/testing-quality-assurance/mocking-frameworks.md) — Provides a comprehensive framework for creating simulated objects and stubbing method calls in Java.
- [Dynamic Mock Objects](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/dependency-mocking/automated-mock-generation/dynamic-mock-objects.md) — Generates runtime proxy objects to simulate dependencies and track interactions during unit tests. ([source](https://github.com/mockito/mockito/blob/main/settings.gradle.kts))
- [Method Stubbing Utilities](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/assertions-and-validation/test-case-definitions/method-stubbing-utilities.md) — Provides utilities for defining stubbed behaviors and return values for mock objects.
- [Legacy Code Isolation Tools](https://awesome-repositories.com/f/testing-quality-assurance/code-quality-review/code-coverage-tools/legacy-code-isolation-tools.md) — Provides isolation tools for legacy Java code by mocking final classes and methods.
- [Final Member Mocks](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/mocking-frameworks/protected-method-mocks/final-member-mocks.md) — Bypasses language restrictions to create mock objects for final classes and methods via instrumentation. ([source](https://github.com/mockito/mockito/wiki/What%27s-new-in-Mockito-2))
- [Test Suite Integrations](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/test-levels-and-types/integration-testing-suites/test-suite-integrations.md) — Integrates mock lifecycles with JUnit and other Java test suites for project-wide verification.

### Programming Languages & Runtimes

- [Proxy Objects](https://awesome-repositories.com/f/programming-languages-runtimes/proxy-objects.md) — Generates runtime proxy objects that intercept and redefine method operations to mimic real classes.
- [Runtime Bytecode Instrumentation](https://awesome-repositories.com/f/programming-languages-runtimes/compiler-interpreter-internals/compiler-infrastructure/intermediate-representations/bytecode/runtime-bytecode-instrumentation.md) — Implements runtime bytecode modification to bypass final modifiers for mocking restricted Java classes.

### Software Engineering & Architecture

- [Behavioral Configuration](https://awesome-repositories.com/f/software-engineering-architecture/default-configuration-values/mock-default-behavior-configurations/behavioral-configuration.md) — Allows the definition of specific return values and behaviors for mocks based on provided arguments.
- [Method Interception Proxies](https://awesome-repositories.com/f/software-engineering-architecture/method-interception-proxies.md) — Provides a dynamic proxy mechanism to intercept method calls and inject simulated behaviors.

### System Administration & Monitoring

- [Method Call Verification](https://awesome-repositories.com/f/system-administration-monitoring/monitoring-and-observability/diagnostic-error-reporting/method-call-verification.md) — Records and validates the execution flow and arguments of method calls for interaction verification.
- [Interaction Verification Utilities](https://awesome-repositories.com/f/system-administration-monitoring/monitoring-and-observability/diagnostic-error-reporting/method-call-verification/interaction-verification-utilities.md) — Provides tools for recording and asserting method call sequences and arguments to verify component interactions.

### Part of an Awesome List

- [Testing Frameworks](https://awesome-repositories.com/f/awesome-lists/devtools/testing-frameworks.md) — Mocking framework with a clean and simple API.
