personal fork
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kayos@tcp.direct 0865f17e8e
Add new built-in templates and fmt
1 month ago
.github/workflows Fix for malfunctioning CI/tests. (#150) 2 years ago
gotests Add new built-in templates and fmt 1 month ago
internal Add new built-in templates and fmt 1 month ago
templates Add new built-in templates and fmt 1 month ago
testdata Add Named option to makes tests a map (#152) 2 years ago
.gitignore Fix for malfunctioning CI/tests. (#150) 2 years ago
CONTRIBUTING.md Update CONTRIBUTING.md 7 years ago
LICENSE Rename LICENCE to LICENSE 7 years ago
README.md Delete .travis.yml and add GitHub Actions badge (#147) 2 years ago
go.mod Run go mod tidy (#117) 3 years ago
go.sum Run go mod tidy (#117) 3 years ago
gotests.go refactoring: code refactoring 1 year ago
gotests_test.go docs: adds notes on failing tests (if run with `-race` flag) 1 year ago

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.