stretchr/testify

Add command to autogenerate mocks from interfaces

Open

#273 opened on Feb 12, 2016

View on GitHub
 (14 comments) (1 reaction) (0 assignees)Go (25,958 stars) (1,704 forks)batch import
enhancementhelp wantedmockery

Description

The best way to use mock is with a program that will automatically generate the code for the mocks based on the interfaces.

mockery pioneered this approach but has some current limitations such as being unable to generate mocks from interfaces from other packages and incomplete mocks from composed interfaces.

goautocomplete addresses these issues but lacks documentation and reviewing the default behaviour to have less verbose go generate declarations.

Whichever implementation we use as a base, requirements would be:

  • Backwards compatibility once released with testify
  • Support for composed interfaces
  • Hability to generate mocks from the stdlib and other packages
  • Simplicity of use with go generate
  • Default arguments generating mocks follow conventions + arguments to override defaults
  • Generated mocks should have documentation for team mates who don't know much about mock
  • Quick way for packages to generate a package with mocks for their exported interfaces

Will follow up with an initial proposal

Contributor guide