personal fork
Go to file
kayos@tcp.direct 0865f17e8e
Add new built-in templates and fmt
2022-08-26 03:12:46 -07:00
.github/workflows Fix for malfunctioning CI/tests. (#150) 2021-03-15 21:05:28 -04:00
gotests Add new built-in templates and fmt 2022-08-26 03:12:46 -07:00
internal Add new built-in templates and fmt 2022-08-26 03:12:46 -07:00
templates Add new built-in templates and fmt 2022-08-26 03:12:46 -07:00
testdata Add Named option to makes tests a map (#152) 2021-03-27 15:36:20 -04:00
.gitignore Fix for malfunctioning CI/tests. (#150) 2021-03-15 21:05:28 -04:00
CONTRIBUTING.md Update CONTRIBUTING.md 2016-03-19 17:51:55 -04:00
LICENSE Rename LICENCE to LICENSE 2016-02-08 16:09:16 -05:00
README.md Delete .travis.yml and add GitHub Actions badge (#147) 2020-12-26 20:31:38 -03:00
go.mod Run go mod tidy (#117) 2019-11-16 08:34:43 +01:00
go.sum Run go mod tidy (#117) 2019-11-16 08:34:43 +01:00
gotests.go refactoring: code refactoring 2021-05-20 16:39:28 +03:00
gotests_test.go docs: adds notes on failing tests (if run with `-race` flag) 2021-05-20 17:45:09 +03:00

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.