json2test

package
v6.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EventParser

func EventParser(h ...Handler) io.WriteCloser

EventParser returns a Writer that parses events and hands each event to all handlers h.

Types

type Action

type Action string

Action is a TestEvent action.

const (
	Run       Action = "run"
	Pause     Action = "pause"
	Continue  Action = "cont"
	Pass      Action = "pass"
	Fail      Action = "fail"
	Skip      Action = "skip"
	Output    Action = "output"
	Benchmark Action = "benchmark"
)

These are the possible Actions generated by `go test -json` or `test2json`.

type Handler

type Handler interface {
	Handle(e TestEvent)
}

Handler is a callback for TestEvent events.

type TestCollector

type TestCollector struct {

	// Package collects all output for a particular package.
	Packages map[string]string

	// Tests are indexed by fully-qualified packageName.TestName strings.
	Tests map[string]*TestResult
	// contains filtered or unexported fields
}

func NewTestCollector

func NewTestCollector() *TestCollector

NewTestCollector returns a Handler that collects test results.

func (*TestCollector) Handle

func (tc *TestCollector) Handle(e TestEvent)

Handle implements Handler.

type TestEvent

type TestEvent struct {
	Time    time.Time `json:",omitempty"`
	Action  Action
	Package string  `json:",omitempty"`
	Test    string  `json:",omitempty"`
	Elapsed float64 `json:",omitempty"`
	Output  string  `json:",omitempty"`
}

TestEvent is an event generated by `test2json`.

type TestKind

type TestKind int
const (
	KindTest TestKind = iota
	KindBenchmark
)

type TestResult

type TestResult struct {
	Kind       TestKind
	State      TestState
	FullOutput string
}

TestResult is an individual tests' outcome.

type TestState

type TestState int
const (
	StateSkip TestState = iota
	StateFail
	StatePass
	StatePaused
	StateRunning
)

Jump to

Keyboard shortcuts

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