https://github.com/hexdigest/gounit
  
  
    Unit tests generator for Go programming language 
    https://github.com/hexdigest/gounit
  
generator go golang unit-testing
        Last synced: 6 months 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-17T09:38:42.000Z (about 7 years ago)
- Last Synced: 2024-11-16T23:32:38.450Z (12 months ago)
- Topics: generator, go, golang, unit-testing
- Language: Go
- Size: 181 KB
- Stars: 79
- 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 [](https://github.com/hexdigest/gounit/blob/master/LICENSE) [](https://travis-ci.org/hexdigest/gounit) [](https://coveralls.io/github/hexdigest/gounit?branch=master) [](https://goreportcard.com/report/github.com/hexdigest/gounit) [](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

## 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 list
    gounit 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.