Documentation
¶
Overview ¶
Package goparse contains logic for parsing Go files. Specifically it parses source and test files into domain models for generating tests.
Package gotests contains the core logic for generating table-driven tests.
Index ¶
- Variables
- func IsFileExist(path string) bool
- type Expression
- type Field
- type Function
- func (f *Function) FullName() string
- func (f *Function) IsNaked() bool
- func (f *Function) OnlyReturnsError() bool
- func (f *Function) OnlyReturnsOneValue() bool
- func (f *Function) ReturnsMultiple() bool
- func (f *Function) TestName() string
- func (f *Function) TestParameters() []*Field
- func (f *Function) TestResults() []*Field
- type GeneratedTest
- type Header
- type Import
- type Options
- type Parser
- type Path
- type Receiver
- type Result
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrEmptyFile = errors.New("file is empty")
ErrEmptyFile represents an empty file error.
Functions ¶
func IsFileExist ¶
Types ¶
type Expression ¶
func (*Expression) String ¶
func (e *Expression) String() string
type Field ¶
type Field struct {
Name string
Type *Expression
Index int
}
func (*Field) IsBasicType ¶
type Function ¶
type Function struct {
Name string
IsExported bool
Receiver *Receiver
Parameters []*Field
Results []*Field
ReturnsError bool
}
func (*Function) OnlyReturnsError ¶
func (*Function) OnlyReturnsOneValue ¶
func (*Function) ReturnsMultiple ¶
func (*Function) TestParameters ¶
func (*Function) TestResults ¶
type GeneratedTest ¶
type GeneratedTest struct {
Path string // The test file's absolute path.
Functions []*Function // The functions with new test methods.
}
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
Parallel bool // Print tests that runs the subtests in parallel.
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.
type Parser ¶
type Parser struct {
// The importer to resolve packages from import paths.
Importer types.Importer
}
Parser can parse Go files.
Click to show internal directories.
Click to hide internal directories.