Skip to content
Unit tests generator for Go programming language
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd/gounit fixed empty template list after installation Aug 3, 2018
templates added simple and testify templates Aug 16, 2018
vendor introduced subcommands and templates Jun 11, 2018
.gitignore introduced subcommands and templates Jun 11, 2018
.travis.yml removed check against go master from .travis.yml Jun 11, 2018
Gopkg.lock introduced subcommands and templates Jun 11, 2018
Gopkg.toml introduced subcommands and templates Jun 11, 2018
LICENSE initial commit Feb 5, 2018
Makefile initial commit Feb 5, 2018
README.md updated readme Aug 17, 2018
client.go added -t flag for gen command and switched to templates' names instea… Aug 2, 2018
command.go introduced subcommands and templates Jun 11, 2018
command_test.go
errors.go introduced subcommands and templates Jun 11, 2018
errors_test.go added more tests Jun 11, 2018
func.go refactoring to introduce interactive mode Feb 7, 2018
func_test.go more tests Feb 8, 2018
generator.go
generator_test.go fixed test for go1.10.3 Aug 16, 2018
helpers.go
helpers_test.go work with broken code Feb 25, 2018

README.md

GoUnit License Build Status Coverage Status Go Report Card GoDoc

GoUnit is a commandline tool that generates tests stubs based on source function or method signature.

There are plugins for

Demo

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 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 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 from Stdin in a loop and produces JSON responses 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.

You can’t perform that action at this time.