# uber-go/mock

**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/uber-go-mock).**

_How this analysis was created: the description and tags below were written by an AI model that read this project's README and public documentation pages; stars, license and language come straight from the GitHub API. The model does not read the source code._

3,375 stars · 167 forks · Go · Apache-2.0

## Links

- GitHub: https://github.com/uber-go/mock
- awesome-repositories: https://awesome-repositories.com/repository/uber-go-mock.md

## Description

This project is a framework for generating mock implementations of interfaces to isolate dependencies and verify method interactions during unit testing in Go. It provides tools to simulate external dependencies by creating controlled mock objects, allowing developers to test components in isolation without requiring real service connections.

The library distinguishes itself through its use of static interface reflection to generate type-safe mock structures during the build process. It features a fluent assertion API that enables developers to define expected method calls, validate arguments using matchers, and enforce specific call sequences. Furthermore, it supports dynamic behavior injection, allowing for the definition of custom logic via anonymous functions to simulate complex side effects.

The framework covers a broad range of testing capabilities, including automated assertion of function interactions and the configuration of stubbed behavior. It also provides mechanisms for customizing error reporting to clarify discrepancies between expected and actual method calls during test failures. The project is distributed as a command-line tool and library for integration into automated test suites.

## Tags

### Testing & Quality Assurance

- [Go Interface](https://awesome-repositories.com/f/testing-quality-assurance/mocking-frameworks/go-interface.md) — Provides a framework for generating mock implementations of interfaces to isolate dependencies and verify method calls.
- [Mock Call Count Verification](https://awesome-repositories.com/f/testing-quality-assurance/api-expectation-frameworks/interaction-expectations/ordered/mock-call-order-verifications/mock-call-count-verification.md) — Asserts that specific methods receive expected arguments and return predefined values during test execution. ([source](https://github.com/uber-go/mock/blob/main/README.md))
- [Dependency-Mocked Unit Testers](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-isolation/middleware-unit-testing/dependency-mocked-unit-testers.md) — Isolates code components by replacing external dependencies with controlled mock objects for reliable unit testing.
- [Go Testing Frameworks](https://awesome-repositories.com/f/testing-quality-assurance/go-testing-frameworks.md) — Offers a comprehensive toolset for simulating dependencies and asserting behavior within Go test suites.
- [Compile-Time Mock Generation](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/dependency-mocking/automated-mock-generation/compile-time-mock-generation.md) — Generates mock implementations during the build process to ensure type safety and avoid runtime reflection.
- [Interface-to-Mock Generators](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/dependency-mocking/automated-mock-generation/interface-to-mock-generators.md) — Analyzes interface definitions to automatically generate mock structures for dependency isolation.
- [Mock Behavior Configuration](https://awesome-repositories.com/f/testing-quality-assurance/mock-behavior-configuration.md) — Defines custom logic for mock methods using anonymous functions to simulate complex side effects. ([source](https://github.com/uber-go/mock/blob/main/README.md))
- [Fluent Assertions](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/assertions-and-validation/assertion-validation-utilities/fluent-assertions.md) — Provides a chainable, readable API for defining expected method calls and return values in tests.
- [Interaction Sequence Orderers](https://awesome-repositories.com/f/testing-quality-assurance/testing-infrastructure-management/test-execution-management/execution-ordering/interaction-sequence-orderers.md) — Enforces strict ordering and frequency requirements for method calls on mock objects during test execution.

### Programming Languages & Runtimes

- [Interface Mock Generators](https://awesome-repositories.com/f/programming-languages-runtimes/go-mocking-libraries/interface-mock-generators.md) — Generates mock implementations from Go interfaces to simulate dependencies without requiring real service connections.

### Development Tools & Productivity

- [Automated Test Execution](https://awesome-repositories.com/f/development-tools-productivity/debugging-profiling-testing/test-execution-management/automated-test-execution.md) — Verifies that functions receive expected arguments and return correct values during automated test execution.

### Software Engineering & Architecture

- [Dynamic Behavior Injection](https://awesome-repositories.com/f/software-engineering-architecture/dynamic-behavior-injection.md) — Allows overriding mock method logic at runtime using anonymous functions to simulate complex side effects.
- [Argument Matchers](https://awesome-repositories.com/f/software-engineering-architecture/static-type-checkers/validation-logic/cli-argument-validators/test-argument-validators/argument-matchers.md) — Validates method arguments against predefined criteria to ensure interactions meet test expectations.
