https://github.com/rdeusser/gotests
Generate Go tests from your source code
https://github.com/rdeusser/gotests
go golang test-generation testing-tools
Last synced: 3 months ago
JSON representation
Generate Go tests from your source code
- Host: GitHub
- URL: https://github.com/rdeusser/gotests
- Owner: rdeusser
- License: apache-2.0
- Created: 2019-02-04T19:37:02.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-04T21:09:47.000Z (almost 7 years ago)
- Last Synced: 2025-03-20T21:50:04.335Z (10 months ago)
- Topics: go, golang, test-generation, testing-tools
- Language: Go
- Size: 12.2 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gotests [](https://github.com/rdeusser/gotests/blob/master/LICENSE) [](https://godoc.org/github.com/rdeusser/gotests) [](https://travis-ci.org/rdeusser/gotests) [](https://goreportcard.com/report/github.com/rdeusser/gotests)
**This is a fork of [cweill's version](https://github.com/cweill/gotests) of gotests to fix some issues and add my own flavor.**
`gotests` makes writing Go tests easy. It's a Go commandline tool that generates [table driven tests](https://github.com/golang/go/wiki/TableDrivenTests) based on its target source files' function and method signatures. Any new dependencies in the test files are automatically imported.
## Installation
__Minimum Go version:__ Go 1.11
Use [`go get`](https://golang.org/cmd/go/#hdr-Download_and_install_packages_and_dependencies) to install and update:
```sh
$ go get -u github.com/rdeusser/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`.
```sh
$ gotests [options] PATH ...
```
Available options:
```
-all generate go tests for all functions and methods
-excl regexp. generate go tests for functions and methods that don't
match. Takes precedence over -only, -exported, and -all
-exported generate go tests for exported functions and methods. Takes
precedence over -only and -all
-i print test inputs in error messages
-only regexp. generate go tests for functions and methods that match only.
Takes precedence over -all
-w write output to (test) files instead of stdout
-nosubtests disable subtest generation. Only available for Go 1.7+
-template_dir optional. Path to a directory containing custom test code templates
```
## License
`gotests` is released under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).