barum / gomock

Automatically exported from code.google.com/p/gomock
Apache License 2.0
0 stars 0 forks source link

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.

Installation

Once you have installed Go, run these commands to install the gomock package and the mockgen tool:

go install code.google.com/p/gomock/gomock
go install code.google.com/p/gomock/mockgen

Documentation

After installing, you can use go doc to get documentation:

go doc code.google.com/p/gomock/gomock

Alternatively, there is an online reference for the package hosted on GoPkgDoc here.

Running mockgen

The mockgen command is used to generate source code for a mock class given a Go source file containing interfaces to be mocked. It supports the following flags:

For an example of the use of mockgen, see the sample/ directory. In simple cases, you will need only the -source flag.

TODO: Brief overview of how to create mock objects and set up expectations, and an example.