Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hexdigest/gounit
Unit tests generator for Go programming language
https://github.com/hexdigest/gounit
generator go golang unit-testing
Last synced: about 1 month ago
JSON representation
Unit tests generator for Go programming language
- Host: GitHub
- URL: https://github.com/hexdigest/gounit
- Owner: hexdigest
- License: other
- Created: 2018-02-05T00:08:30.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-17T09:38:42.000Z (over 6 years ago)
- Last Synced: 2024-08-03T15:06:15.869Z (5 months ago)
- Topics: generator, go, golang, unit-testing
- Language: Go
- Size: 181 KB
- Stars: 80
- Watchers: 8
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - gounit - Unit tests generator for Go programming language - ★ 14 (Go Generate Tools)
- awesome-go-extra - gounit - 02-05T00:08:30Z|2018-08-17T09:38:42Z| (Go Generate Tools / Routers)
README
# GoUnit [![License](https://img.shields.io/badge/license-Apache%202.0-green.svg)](https://github.com/hexdigest/gounit/blob/master/LICENSE) [![Build Status](https://travis-ci.org/hexdigest/gounit.svg?branch=master)](https://travis-ci.org/hexdigest/gounit) [![Coverage Status](https://coveralls.io/repos/github/hexdigest/gounit/badge.svg?branch=master)](https://coveralls.io/github/hexdigest/gounit?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/hexdigest/gounit)](https://goreportcard.com/report/github.com/hexdigest/gounit) [![GoDoc](https://godoc.org/github.com/hexdigest/gounit?status.svg)](http://godoc.org/github.com/hexdigest/gounit)
GoUnit is a commandline tool that generates tests stubs based on source function or method signature.
There are plugins for
* [Vim](https://github.com/hexdigest/gounit-vim)
* [Emacs](https://github.com/hexdigest/GoUnit-Emacs)
* [Atom](https://github.com/hexdigest/atom-gounit)
* [Sublime](https://github.com/hexdigest/gounit-sublime)## Demo
![demo](https://github.com/hexdigest/gounit-vim/blob/master/demo.gif)
## Installation
```
go get -u github.com/hexdigest/gounit/cmd/gounit
```## Usage of GoUnit
This will generate test stubs for all functions and methods in file.go
```
$ gounit gen -i file.go
```Run `gounit help` for more options
## Custom test templates
If you're not satisfied with the code produced by the default GoUnit test template you can always write your own!
You can use [minimock template](https://github.com/hexdigest/gounit/blob/master/templates/minimock) as an example.
Here is how to add and switch to the custom template:```
$ curl https://raw.githubusercontent.com/hexdigest/gounit/master/templates/minimock > minimock
$ gounit template add minimock
$ gounit template listgounit templates installed
* default
minimock$ gounit template use minimock
```Minimock template produces test stubs that are aware of the mocks generated by the [minimock](https://github.com/gojuno/minimock) mock generator.
By using both of these tools you can automate the process of writing tests and focus on your test cases rather than routine operations.## Integration with editors and IDEs
To ease an integration of GoUnit with IDEs "gen" subcommand has a "-json" flag.
When -json flag is passed GoUnit reads [JSON requests](https://github.com/hexdigest/gounit/blob/master/client.go#L5) from Stdin in a loop and produces [JSON responses](https://github.com/hexdigest/gounit/blob/master/client.go#L16) with generated test(s) that are written to Stdout.
Using this mode you can generate as many tests as you want by running GoUnit executable only once.