gtr

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 2 Imported by: 3

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

This section is empty.

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 added in v2.1.0

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 added in v2.1.0

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() 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.

Jump to

Keyboard shortcuts

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