mockgo

command module
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2023 License: MIT Imports: 15 Imported by: 0

README

mockgo - mock generator for type aliased mock

GoDoc Actions/Go Go Report Card

mockgo generates a test mock for tye type.

Getting started

How to install or update.

$ go install github.com/koron/mockgo@latest

Generate mock for your types.

$ cd ~/go/src/github.com/your/project/package
$ mockgo -pacakge github.com/thirdparity/libarary TargetType1 TargetType2
Usage
$ mockgo {OPTIONS} -package {package name or relative path} [target classes...]
Options
  • -fortest - generate mock for plain test, without +mock tag)

  • -mocksuffix - add Mock suffix to generated mock types

  • -noformat - write mock without formatting (goimports equivalent)

  • -output - specify output directory (default ., current directory)

  • -package - mandatory, specify a package where types are which generate mock for.

    starts with ./ or ../, you can use relative path for this.

  • -verbose - show verbose/debug messages to stderr

Target classes

Where [target classes...] accepts two forms of name to specify type.

  • OriginalTypename - Mock type name will be same with OriginalTypename

    When -mocksuffix given, OriginalTypenameMock is used for mock type.

  • OriginalTypename:MockTypename - Specify both original and mock type names

    -mocksuffix is ignored.

Advanced usage

Based component differential

for interface based component, -fortest and -mocksuffix will work well.

mockgo -package ./ -outdir . -fortest -mocksuffix Interface1 Interface2

for struct based component, this command will work well.

mockgo -package ../pkgA -outdir . Component1 Component2

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package mockrt provides mock runtime for mockgo
Package mockrt provides mock runtime for mockgo
Package mockrt3 provides mock runtime for mockgo
Package mockrt3 provides mock runtime for mockgo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL