annotations

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FixtureAnnotation used to label a function as a fixture
	FixtureAnnotation = "@fixture"

	// OnceFixtureAnnotation used to label a function as a fixture to be called once
	OnceFixtureAnnotation = "@onceFixture"

	// TestAnnotation used to label a function as a test
	TestAnnotation = "@test"

	// BeforeTestAnnotation used to label a function as a before test hook
	BeforeTestAnnotation = "@beforeTest"

	// AfterTestAnnotation used to label a function as a after test hook
	AfterTestAnnotation = "@afterTest"

	// TestLabelAnnotation used to introduce a new test Label.
	TestLabelAnnotation = "@testLabel"

	// DisableAutoLabellingAnnotation can be used to toggle the auto matching of tests.
	DisableAutoLabellingAnnotation = "@disableAutoLabelling"

	DefaultTestLabel = unitTestLabel
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Function

type Function struct {
	File    string
	Package *ast.Package
	Decl    *ast.FuncDecl
}

Function represents a function declaration.

func (*Function) Comment

func (f *Function) Comment() string

func (*Function) HasAfterTestAnnotation

func (f *Function) HasAfterTestAnnotation() bool

HasAfterTestAnnotation returns true if the function has a afterTest annotation.

func (*Function) HasBeforeTestAnnotation

func (f *Function) HasBeforeTestAnnotation() bool

HasBeforeTestAnnotation returns true if the function has a beforeTest annotation.

func (*Function) HasFixtureAnnotation

func (f *Function) HasFixtureAnnotation() bool

HasFixtureAnnotation returns true if the function has a fixture annotation.

func (*Function) HasOnceFixtureAnnotation

func (f *Function) HasOnceFixtureAnnotation() bool

HasOnceFixtureAnnotation returns true if the function has a onceFixture annotation.

func (*Function) HasTestAnnotation

func (f *Function) HasTestAnnotation() bool

HasTestAnnotation returns true if the function has a test annotation.

func (*Function) Name

func (f *Function) Name() string

func (*Function) String

func (f *Function) String() string

type LabelFunction

type LabelFunction struct {
	*Function
	Labels []string
}

type ParseResult

type ParseResult struct {
	Package *ast.Package

	DefaultTestLabel string
	// Label name => prefix.
	TestLabels   map[string][]string
	Fixtures     []*Function
	OnceFixtures []*Function
	Tests        []*LabelFunction
	BeforeTests  []*Function
	AfterTests   []*Function

	Warnings []string
}

ParseResult holds the package and functions parsed.

func Parse

func Parse(pkgDir string, filePrefix string, autoLabel bool) (*ParseResult, error)

Parse returns the parsed result of the package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL