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
99.99% Uptime for Your Most Critical Databases Icon
99.99% Uptime for Your Most Critical Databases

Sub-second maintenance. 2x read/write performance. Built-in vector search for AI apps.

Cloud SQL Enterprise Plus delivers near-zero downtime with 35 days of point-in-time recovery. Supports MySQL, PostgreSQL, and SQL Server.
Try 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