gtr

package
v2.0.0-...-e9c7f1d Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package gtr defines a standard test report format and provides convenience methods to create and convert reports.

Index

Constants

This section is empty.

Variables

View Source
var ErrPackageCoverageIsTooLow = errors.New("coverage is to low")

Functions

func TrimPrefixSpaces

func TrimPrefixSpaces(line string, indent int) string

TrimPrefixSpaces trims the leading whitespace of the given line using the indentation level of the test. Printing logs in a Go test is typically prepended by blocks of 4 spaces to align it with the rest of the test output. TrimPrefixSpaces intends to only trim the whitespace added by the Go test command, without inadvertently trimming whitespace added by the test author.

Types

type Error

type Error struct {
	ID       int
	Name     string
	Duration time.Duration
	Cause    string
	Output   []string
}

Error contains details of a build or runtime error.

type Package

type Package struct {
	Name       string
	Timestamp  time.Time
	Duration   time.Duration
	Coverage   float64
	Output     []string
	Properties []Property

	Tests []Test

	BuildError Error
	RunError   Error
}

Package contains build and test results for a single package.

func (*Package) AddProperty

func (p *Package) AddProperty(name, value string)

AddProperty appends a name/value property in the current package.

func (*Package) SetProperty

func (p *Package) SetProperty(key, value string)

SetProperty stores a key/value property in the current package. If a property with the given key already exists, its old value will be overwritten with the given value.

type Property

type Property struct {
	Name, Value string
}

Property is a name/value property.

type Report

type Report struct {
	Packages []Package
}

Report contains the build and test results of a collection of packages.

func (*Report) IsSuccessful

func (r *Report) IsSuccessful(cMap map[string]*UnitCfg) bool

IsSuccessful returns true if none of the packages in this report have build or runtime errors and all tests passed without failures or were skipped.

type Result

type Result int

Result is the result of a test.

const (
	Unknown Result = iota
	Pass
	Fail
	Skip
)

Test results.

func (Result) String

func (r Result) String() string

type Test

type Test struct {
	ID       int
	Name     string
	Duration time.Duration
	Result   Result
	Level    int
	Output   []string
	Data     map[string]interface{}
}

Test contains the results of a single test.

func NewTest

func NewTest(id int, name string) Test

NewTest creates a new Test with the given id and name.

type UnitCfg

type UnitCfg struct {
	MinCover       float64 `json:"min_cover" yaml:"min_cover"`
	TolerateErrors bool    `json:"tolerate_errors" yaml:"tolerate_errors"`
}

Jump to

Keyboard shortcuts

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