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
MongoDB Atlas runs apps anywhere Icon
MongoDB Atlas runs apps anywhere

Deploy in 115+ regions with the modern database for every enterprise.

MongoDB Atlas gives you the freedom to build and run modern applications anywhere—across AWS, Azure, and Google Cloud. With global availability in over 115 regions, Atlas lets you deploy close to your users, meet compliance needs, and scale with confidence across any geography.
Start Free
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