Generate ready-to-use mock structs for any Go interface so you can test a function without its real dependencies.
Set expectations on method calls in tests, verify a database method was called exactly once with the right arguments.
Replace a slow external API or file system with a fast, controllable fake during unit testing.
Drop generated mocks into table-driven tests to cover success and error paths without real infrastructure.
Install the mockery binary via go install or brew, then run it against your Go interface files.
Mockery is a code generation tool for Go developers who write automated tests. In Go, when you want to test a piece of code in isolation, you often need a fake version of a dependency, called a mock, that you can control in your test. Writing these mock objects by hand is repetitive and error-prone. Mockery reads your Go interfaces and generates that boilerplate code for you automatically. The generated mocks are built on top of the testify/mock package, which is a widely used Go testing library. Once mockery generates a mock for an interface, you can use it in your tests to set expectations, verify calls were made, and return specific values without needing the real implementation. The repository README is brief and points to a separate documentation site for full usage details, configuration options, and examples. It notes that development tasks are managed with taskfile.dev. The project has accumulated over 7,100 GitHub stars, suggesting it is widely adopted in the Go testing ecosystem, but the README itself does not describe configuration options or advanced features in detail.
← vektra on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.