Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cweill/gotests
Automatically generate Go test boilerplate from your source code.
https://github.com/cweill/gotests
code-generator commandline go go-test go-testing golang golang-application golang-testing golang-tools gotests table-driven-test table-driven-testing test-driven-development test-generation testing testing-golang testing-tools
Last synced: 3 days ago
JSON representation
Automatically generate Go test boilerplate from your source code.
- Host: GitHub
- URL: https://github.com/cweill/gotests
- Owner: cweill
- License: apache-2.0
- Created: 2016-01-19T05:06:02.000Z (almost 9 years ago)
- Default Branch: develop
- Last Pushed: 2023-09-12T00:02:48.000Z (over 1 year ago)
- Last Synced: 2024-11-18T21:13:35.610Z (24 days ago)
- Topics: code-generator, commandline, go, go-test, go-testing, golang, golang-application, golang-testing, golang-tools, gotests, table-driven-test, table-driven-testing, test-driven-development, test-generation, testing, testing-golang, testing-tools
- Language: Go
- Homepage:
- Size: 12.3 MB
- Stars: 4,960
- Watchers: 80
- Forks: 345
- Open Issues: 63
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- go-awesome - gotests - Automatically generate test files based on the source code (Open source library / Test)
- awesome-go - gotests - Generate Go tests from your source code. Stars:`5.0K`. (Go Generate Tools / Routers)
- awesome-list - gotests - Automatically generate Go test boilerplate from your source code. (Containers & Language Extentions & Linting / For Go)
- awesome-go - gotests - Generate Go tests from your source code. - ★ 1487 (Go Generate Tools)
- awesome-go-extra - gotests - 01-19T05:06:02Z|2022-04-14T11:12:22Z| (Go Generate Tools / Routers)
README
# gotests [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/cweill/gotests/blob/master/LICENSE) [![godoc](https://img.shields.io/badge/go-documentation-blue.svg)](https://godoc.org/github.com/cweill/gotests) [![Build Status](https://github.com/cweill/gotests/workflows/Go/badge.svg)](https://github.com/cweill/gotests/actions) [![Coverage Status](https://coveralls.io/repos/github/cweill/gotests/badge.svg?branch=master)](https://coveralls.io/github/cweill/gotests?branch=master) [![codebeat badge](https://codebeat.co/badges/7ef052e3-35ff-4cab-88f9-e13393c8ab35)](https://codebeat.co/projects/github-com-cweill-gotests) [![Go Report Card](https://goreportcard.com/badge/github.com/cweill/gotests)](https://goreportcard.com/report/github.com/cweill/gotests)
`gotests` makes writing Go tests easy. It's a Golang 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.
## Demo
The following shows `gotests` in action using the [official Sublime Text 3 plugin](https://github.com/cweill/GoTests-Sublime). Plugins also exist for [Emacs](https://github.com/damienlevin/GoTests-Emacs), also [Emacs](https://github.com/s-kostyaev/go-gen-test), [Vim](https://github.com/buoto/gotests-vim), [Atom Editor](https://atom.io/packages/gotests), [Visual Studio Code](https://github.com/Microsoft/vscode-go), and [IntelliJ Goland](https://www.jetbrains.com/help/go/run-debug-configuration-for-go-test.html).
![demo](https://github.com/cweill/GoTests-Sublime/blob/master/gotests.gif)
## Installation
__Minimum Go version:__ Go 1.6
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/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`.
```sh
$ 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](CONTRIBUTING.md).
## License
`gotests` is released under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).