gotests

从您的源代码中自动生成 Go 测试模板。「Generate Go tests from your source code.」

Github星跟踪图

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

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

  -template_dir         Path to a directory containing custom test code templates. Takes
                         precedence over -template

  -template             Specify custom test code templates, e.g. testify

  -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.

主要指标

概览
名称与所有者cweill/gotests
主编程语言Go
编程语言Go (语言数: 1)
平台Linux, Mac, Windows
许可证Apache License 2.0
所有者活动
创建于2016-01-19 05:06:02
推送于2023-09-12 00:02:48
最后一次提交2021-03-27 16:00:37
发布数11
最新版本名称v1.6.0 (发布于 )
第一版名称v1.0-beta (发布于 )
用户参与
星数5.1k
关注者数79
派生数347
提交数383
已启用问题?
问题数101
打开的问题数43
拉请求数51
打开的拉请求数20
关闭的拉请求数19
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?