gomock is a mocking framework for the Go programming language. It integrates well with Go's built-in testing package, but can be used in other contexts too. Once you have installed Go, install the mockgen tool. If you have not done so already be sure to add $GOPATH/bin to your PATH. If you use mockgen in your CI pipeline, it may be more appropriate to fixate on a specific mockgen version. Source mode generates mock interfaces from a source file. It is enabled by using the -source flag. Other flags that may be useful in this mode are -imports and -aux_files. Reflect mode generates mock interfaces by building a program that uses reflection to understand interfaces. It is enabled by passing two non-flag arguments, an import path, and a comma-separated list of symbols. The mockgen command is used to generate source code for a mock class given a Go source file containing interfaces to be mocked.

Features

  • Source mode operation
  • Reflect mode operation
  • Generate source code for mock classes
  • Modify failure messages
  • Integrates well with Go's built-in testing package
  • Generate mock interfaces

Project Samples

Project Activity

See All Activity >

License

Apache License V2.0

Follow gomock

gomock Web Site

Other Useful Business Software
Our Free Plans just got better! | Auth0 Icon
Our Free Plans just got better! | Auth0

With up to 25k MAUs and unlimited Okta connections, our Free Plan lets you focus on what you do best—building great apps.

You asked, we delivered! Auth0 is excited to expand our Free and Paid plans to include more options so you can focus on building, deploying, and scaling applications without having to worry about your security. Auth0 now, thank yourself later.
Try free now
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of gomock!

Additional Project Details

Programming Language

Go

Related Categories

Go Software Testing Tool, Go Frameworks

Registered

2021-09-06