A mock code autogenerator for Go interfaces using testify/mock to eliminate boilerplate.
Mockery is a Go tool that automatically generates mock implementations for Go interfaces using the testify/mock package. It solves the problem of writing repetitive boilerplate code for mocks in testing by programmatically creating mock structs from interface definitions. This allows developers to quickly set up test doubles without manual implementation.
Go developers who write unit tests and need to mock dependencies, particularly those already using or planning to use the testify/mock package for their testing framework.
Developers choose Mockery because it eliminates the tedious, error-prone process of manually writing mock code, saving time and ensuring consistency with testify/mock conventions. Its automated generation reduces maintenance overhead and integrates seamlessly into existing Go test workflows.
A mock code autogenerator for Go
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically creates mock structs from Go interfaces, eliminating the need for manual coding as stated in the README, saving significant development time.
Generates mocks specifically for the testify/mock package, ensuring compatibility and consistent testing patterns across Go projects.
Provides a simple command-line tool with configuration options, making it easy to integrate into development workflows and scripts.
Drastically cuts down on repetitive mock implementation code, allowing developers to focus on test logic rather than setup.
Tightly coupled with testify/mock; switching to another testing framework would require abandoning or rewriting generated mocks.
Requires installing and maintaining Mockery as an additional CLI tool, complicating setup and CI/CD pipelines compared to built-in solutions.
Only generates mocks for Go interfaces, so it cannot handle non-interface types or other languages, restricting its use cases.