simplemock

command module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: MIT Imports: 11 Imported by: 0

README

simplemock

simplemock is a simplistic and opinionated Go mock generator designed to be used with //go:generate directives. It generates minimalistic mock implementations for interfaces, making unit tests more clear and descriptive without complicated frameworks and configurations.

Installation

go install github.com/mcriley821/simplemock@latest

Usage

Invoke simplemock with -help to get up-to-date usage:

simplemock -help
//go:generate simplemock -iface {interface} -out {filename}

The provided interface must either be in the same package as the directive, or accessible via imported packages.

simplemock generates a struct type that implements the provided interface. This struct holds func data members named after the corresponding interface method with a Func suffix. In each mock method, the corresponding func data member is called if it is non-nil - otherwise panic is called.

Examples

See the end-to-end test directories for concrete examples of the different ways to utilize simplemock.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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