gotests: github.com/cweill/gotests Index | Files | Directories

package gotests

import "github.com/cweill/gotests"

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

Index

Package Files

gotests.go

type GeneratedTest Uses

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 Uses

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 Uses

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.
    Template       string                 // Name of custom template set
    TemplateDir    string                 // Path to custom template set
    TemplateParams map[string]interface{} // Custom external parameters
}

Options provides custom filters and parameters for generating tests.

Directories

PathSynopsis
gotestsA commandline tool for generating table-driven Go tests.
gotests/processPackage process is a thin wrapper around the gotests library.
internal/goparserPackage goparse contains logic for parsing Go files.
internal/input
internal/models
internal/output
internal/render
internal/render/bindata
templatesgo:generate esc -include=.*\.tmpl -o=tmpl.go -pkg=templates ./

Package gotests imports 11 packages (graph) and is imported by 2 packages. Updated 2019-11-16. Refresh now. Tools for package owners.