reporting

package
v0.0.0-...-954e483 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package reporting contains internal functionality related to console reporting and output. Although this package has exported names is not intended for public consumption. See the examples package for how to use this project.

Index

Constants

View Source
const CloseJson = "<-<-<-CLOSE-JSON<-<-<" // "⌫"
View Source
const OpenJson = ">->->OPEN-JSON->->->" // "⌦"

Variables

This section is empty.

Functions

func NewConsole

func NewConsole() io.Writer

func NewDotReporter

func NewDotReporter(out *Printer) *dot

func NewGoTestReporter

func NewGoTestReporter() *gotestReporter

func NewProblemReporter

func NewProblemReporter(out *Printer) *problem

func NewReporters

func NewReporters(collection ...Reporter) *reporters

func NewSilentProblemReporter

func NewSilentProblemReporter(out *Printer) *problem

func NewStatisticsReporter

func NewStatisticsReporter(out *Printer) *statistics

func NewStoryReporter

func NewStoryReporter(out *Printer) *story

func PrintConsoleStatistics

func PrintConsoleStatistics()

func QuietMode

func QuietMode()

QuietMode disables all console output symbols. This is only meant to be used for tests that are internal to goconvey where the output is distracting or otherwise not needed in the test output.

func SuppressConsoleStatistics

func SuppressConsoleStatistics()

Types

type AssertionResult

type AssertionResult struct {
	File       string
	Line       int
	Expected   string
	Actual     string
	Failure    string
	Error      any
	StackTrace string
	Skipped    bool
}

func NewErrorReport

func NewErrorReport(err any) *AssertionResult

func NewFailureReport

func NewFailureReport(failure string, showStack bool) *AssertionResult

func NewSkipReport

func NewSkipReport() *AssertionResult

func NewSuccessReport

func NewSuccessReport() *AssertionResult

type FailureView

type FailureView struct {
	Message  string `json:"Message"`
	Expected string `json:"Expected"`
	Actual   string `json:"Actual"`
}

FailureView is also declared in github.com/smarty/assertions. The json struct tags should be equal in both declarations.

type JsonReporter

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

func NewJsonReporter

func NewJsonReporter(out *Printer) *JsonReporter

func (*JsonReporter) BeginStory

func (self *JsonReporter) BeginStory(story *StoryReport)

func (*JsonReporter) EndStory

func (self *JsonReporter) EndStory()

func (*JsonReporter) Enter

func (self *JsonReporter) Enter(scope *ScopeReport)

func (*JsonReporter) Exit

func (self *JsonReporter) Exit()

func (*JsonReporter) Report

func (self *JsonReporter) Report(report *AssertionResult)

func (*JsonReporter) Write

func (self *JsonReporter) Write(content []byte) (written int, err error)

type Printer

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

func NewPrinter

func NewPrinter(out io.Writer) *Printer

func (*Printer) Dedent

func (self *Printer) Dedent()

func (*Printer) Indent

func (self *Printer) Indent()

func (*Printer) Insert

func (self *Printer) Insert(text string)

func (*Printer) Print

func (self *Printer) Print(message string, values ...any)

func (*Printer) Println

func (self *Printer) Println(message string, values ...any)

type Reporter

type Reporter interface {
	BeginStory(story *StoryReport)
	Enter(scope *ScopeReport)
	Report(r *AssertionResult)
	Exit()
	EndStory()
	io.Writer
}

func BuildDotReporter

func BuildDotReporter() Reporter

func BuildJsonReporter

func BuildJsonReporter() Reporter

func BuildSilentReporter

func BuildSilentReporter() Reporter

func BuildStoryReporter

func BuildStoryReporter() Reporter

type ScopeReport

type ScopeReport struct {
	Title string
	File  string
	Line  int
}

func NewScopeReport

func NewScopeReport(title string) *ScopeReport

type ScopeResult

type ScopeResult struct {
	Title      string
	File       string
	Line       int
	Depth      int
	Assertions []*AssertionResult
	Output     string
}

type StoryReport

type StoryReport struct {
	Test T
	Name string
	File string
	Line int
}

func NewStoryReport

func NewStoryReport(test T) *StoryReport

type T

type T interface {
	Fail()
}

This interface allows us to pass the *testing.T struct throughout the internals of this tool without ever having to import the "testing" package.

Jump to

Keyboard shortcuts

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