Skip to content
Automatically generate Go test boilerplate from your source code.
Go
Branch: develop
Clone or download

Latest commit

178inaba Add parallel to sub test (#121)
* Add parallel to sub test

* Add parallel flag and option

* Fix README

* Add parallel to template

* Fix templates

* Add tests
Latest commit 2435ae5 Apr 13, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gotests Add parallel to sub test (#121) Apr 13, 2020
internal Add parallel to sub test (#121) Apr 13, 2020
templates Add parallel to sub test (#121) Apr 13, 2020
testdata Add parallel to sub test (#121) Apr 13, 2020
.gitignore Move generator files to gen package. Move internal packages to intern… Feb 7, 2016
.travis.yml Add 1.13.x to .travis.yml (#127) Feb 23, 2020
CONTRIBUTING.md Update CONTRIBUTING.md Mar 19, 2016
LICENSE Rename LICENCE to LICENSE Feb 8, 2016
README.md Add parallel to sub test (#121) Apr 13, 2020
go.mod Run go mod tidy (#117) Nov 16, 2019
go.sum Run go mod tidy (#117) Nov 16, 2019
gotests.go Add parallel to sub test (#121) Apr 13, 2020
gotests_test.go Add parallel to sub test (#121) Apr 13, 2020

README.md

gotests License godoc Build Status Coverage Status codebeat badge Go Report Card

gotests makes writing Go tests easy. It's a Golang commandline tool that generates table driven tests based on its target source files' function and method signatures. Any new dependencies in the test files are automatically imported.

Demo

The following shows gotests in action using the official Sublime Text 3 plugin. Plugins also exist for Emacs, also Emacs, Vim, Atom Editor, Visual Studio Code, and IntelliJ Goland.

demo

Installation

Minimum Go version: Go 1.6

Use go get to install and update:

$ go get -u github.com/cweill/gotests/...

Usage

From the commandline, gotests can generate Go tests for specific source files or an entire directory. By default, it prints its output to stdout.

$ gotests [options] PATH ...

Available options:

  -all                  generate tests for all functions and methods

  -excl                 regexp. generate tests for functions and methods that don't
                         match. Takes precedence over -only, -exported, and -all

  -exported             generate tests for exported functions and methods. Takes
                         precedence over -only and -all

  -i                    print test inputs in error messages

  -only                 regexp. generate tests for functions and methods that match only.
                         Takes precedence over -all

  -nosubtests           disable subtest generation when >= Go 1.7

  -parallel             enable parallel subtest generation when >= Go 1.7.

  -w                    write output to (test) files instead of stdout

  -template_dir         Path to a directory containing custom test code templates. Takes
                         precedence over -template. This can also be set via environment
                         variable GOTESTS_TEMPLATE_DIR

  -template             Specify custom test code templates, e.g. testify. This can also
                         be set via environment variable GOTESTS_TEMPLATE

  -template_params_file read external parameters to template by json with file

  -template_params      read external parameters to template by json with stdin

Contributions

Contributing guidelines are in CONTRIBUTING.md.

License

gotests is released under the Apache 2.0 License.

You can’t perform that action at this time.