lib

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package lib is exposing parsers and output generation

Index

Constants

View Source
const (

	// XUnitTemplate is XML template for xunit style reporting
	XUnitTemplate string = `` /* 499-byte string literal not displayed */

	// XMLMultiTemplate is template when we have multiple suites
	XMLMultiTemplate string = `
<testsuites>` + XUnitTemplate + `</testsuites>
`

	// XUnitNetTemplate is XML template for xunit.net
	// see https://xunit.codeplex.com/wikipage?title=XmlFormat
	XUnitNetTemplate string = `` /* 1067-byte string literal not displayed */

)

Variables

View Source
var Options struct {
	// FailOnRace will mark test a failed if there is a race
	FailOnRace bool
}

Options is library options

Functions

func WriteXML

func WriteXML(suites []*Suite, out io.Writer, xmlTemplate string, testTime time.Time)

WriteXML exits xunit XML of tests to out

Types

type LineScanner

type LineScanner struct {
	*bufio.Scanner
	// contains filtered or unexported fields
}

LineScanner scans lines and keep track of line numbers

func NewLineScanner

func NewLineScanner(r io.Reader) *LineScanner

NewLineScanner creates a new line scanner from r

func (*LineScanner) Line

func (ls *LineScanner) Line() int

Line returns the current line number

func (*LineScanner) Scan

func (ls *LineScanner) Scan() bool

Scan advances to next line

type Status

type Status int

Status is test status

const (
	// UnknownStatus means an error status
	UnknownStatus Status = iota
	// Failed means test failed
	Failed
	// Skipped means test was skipped
	Skipped
	// Passed means test passed
	Passed
)

func Token2Status

func Token2Status(token string) Status

Token2Status return matching status for token

type Suite

type Suite struct {
	Name   string
	Time   string
	Status string
	Tests  []*Test
}

Suite of tests (found in some unit testing frameworks)

func (*Suite) Len

func (suite *Suite) Len() int

Len return the number of tests in the suite

func (*Suite) NumFailed

func (suite *Suite) NumFailed() int

NumFailed return number of failed tests in suite

func (*Suite) NumPassed

func (suite *Suite) NumPassed() int

NumPassed return number of passed tests in the suite

func (*Suite) NumSkipped

func (suite *Suite) NumSkipped() int

NumSkipped return number of skipped tests in suite

type SuiteStack

type SuiteStack struct {
	// contains filtered or unexported fields
}

SuiteStack is a stack of test suites

func (*SuiteStack) Pop

func (s *SuiteStack) Pop() *Suite

Pop removes and returns a node from the stack in last to first order.

func (*SuiteStack) Push

func (s *SuiteStack) Push(n *Suite)

Push adds a node to the stack.

type Suites

type Suites []*Suite

Suites is a list of suites

func ParseGocheck

func ParseGocheck(rd io.Reader, suitePrefix string) (Suites, error)

ParseGocheck parses output of "go test -gocheck.vv", returns a list of tests See data/gocheck.out for an example TODO: Refactor to shorter ones

func ParseGotest

func ParseGotest(rd io.Reader, suitePrefix string) (Suites, error)

ParseGotest parser output of gotest TODO: Make it shorter

func (Suites) HasFailures

func (s Suites) HasFailures() bool

HasFailures return true is there's at least one failing suite

type Test

type Test struct {
	Name, Time, Message string
	Status              Status
}

Test data structure

type TestResults

type TestResults struct {
	Suites     []*Suite
	Assembly   string
	RunDate    string
	RunTime    string
	Time       string
	Len        int
	NumPassed  int
	NumFailed  int
	NumSkipped int

	Skipped Status
	Passed  Status
	Failed  Status
}

TestResults is passed to XML template

Jump to

Keyboard shortcuts

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