Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcriley821/simplemock
Go simple mock generator
https://github.com/mcriley821/simplemock
code-generation code-generator code-generators generator go golang golang-cli golang-generator golang-testing golang-tools mock mock-generator mock-generators mock-testing test testing
Last synced: 15 days ago
JSON representation
Go simple mock generator
- Host: GitHub
- URL: https://github.com/mcriley821/simplemock
- Owner: mcriley821
- License: mit
- Created: 2024-09-30T04:29:31.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-13T05:57:06.000Z (2 months ago)
- Last Synced: 2024-10-25T03:44:04.416Z (about 2 months ago)
- Topics: code-generation, code-generator, code-generators, generator, go, golang, golang-cli, golang-generator, golang-testing, golang-tools, mock, mock-generator, mock-generators, mock-testing, test, testing
- Language: Go
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simplemock
`simplemock` is a simplistic and opinionated Go mock generator designed to be
used with [`//go:generate`](https://go.dev/blog/generate) directives. It
generates minimalistic mock implementations for interfaces, making unit tests
more clear and descriptive without complicated frameworks and configurations.## Installation
```bash
go install github.com/mcriley821/simplemock@latest
```## Usage
Invoke `simplemock` with `-help` to get up-to-date usage:```sh
simplemock -help
``````go
//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](./e2e/testdata) test directories for concrete examples of
the different ways to utilize `simplemock`.