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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?