Back to

Package gotests

Latest Go to latest

The latest major version is .

Published: Apr 7, 2019 | License: Apache-2.0 | Module:


Package gotests contains the core logic for generating table-driven tests.


type GeneratedTest

type GeneratedTest struct {
	Path      string             // The test file's absolute path.
	Functions []*models.Function // The functions with new test methods.
	Output    []byte             // The contents of the test file.

A GeneratedTest contains information about a test file with generated tests.

func GenerateTests

func GenerateTests(srcPath string, opt *Options) ([]*GeneratedTest, error)

GenerateTests generates table-driven tests for the function and method signatures defined in the target source path file(s). The source path parameter can be either a Go source file or directory containing Go files.

type Options

type Options struct {
	Only        *regexp.Regexp        // Includes only functions that match.
	Exclude     *regexp.Regexp        // Excludes functions that match.
	Exported    bool                  // Include only exported methods
	PrintInputs bool                  // Print function parameters in error messages
	Subtests    bool                  // Print tests using Go 1.7 subtests
	Importer    func() types.Importer // A custom importer.
	TemplateDir string                // Path to custom template set

Options provides custom filters and parameters for generating tests.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier