reporters

package
v2.22.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 14 Imported by: 32

Documentation

Overview

Ginkgo's Default Reporter

A number of command line flags are available to tweak Ginkgo's default output.

These are documented [here](http://onsi.github.io/ginkgo/#running_tests)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateJSONReport

func GenerateJSONReport(report types.Report, destination string) error

GenerateJSONReport produces a JSON-formatted report at the passed in destination

func GenerateJUnitReport

func GenerateJUnitReport(report types.Report, dst string) error

func GenerateJUnitReportWithConfig added in v2.5.0

func GenerateJUnitReportWithConfig(report types.Report, dst string, config JunitReportConfig) error

func GenerateTeamcityReport

func GenerateTeamcityReport(report types.Report, dst string) error

func MergeAndCleanupJSONReports

func MergeAndCleanupJSONReports(sources []string, destination string) ([]string, error)

MergeJSONReports produces a single JSON-formatted report at the passed in destination by merging the JSON-formatted reports provided in sources It skips over reports that fail to decode but reports on them via the returned messages []string

func MergeAndCleanupJUnitReports

func MergeAndCleanupJUnitReports(sources []string, dst string) ([]string, error)

func MergeAndCleanupTeamcityReports

func MergeAndCleanupTeamcityReports(sources []string, dst string) ([]string, error)

func RenderTimeline added in v2.9.3

func RenderTimeline(spec types.SpecReport, noColor bool) string

func ReportViaDeprecatedReporter deprecated

func ReportViaDeprecatedReporter(reporter DeprecatedReporter, report types.Report)

ReportViaDeprecatedReporter takes a V1 custom reporter and a V2 report and calls the custom reporter's methods with appropriately transformed data from the V2 report.

ReportViaDeprecatedReporter should be called in a `ReportAfterSuite()`

Deprecated: ReportViaDeprecatedReporter method exists to help developer bridge between deprecated V1 functionality and the new reporting support in V2. It will be removed in a future minor version of Ginkgo.

Types

type DefaultReporter

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

func NewDefaultReporter

func NewDefaultReporter(conf types.ReporterConfig, writer io.Writer) *DefaultReporter

func NewDefaultReporterUnderTest

func NewDefaultReporterUnderTest(conf types.ReporterConfig, writer io.Writer) *DefaultReporter

func (*DefaultReporter) DidRun

func (r *DefaultReporter) DidRun(report types.SpecReport)

func (*DefaultReporter) EmitFailure added in v2.3.0

func (r *DefaultReporter) EmitFailure(state types.SpecState, failure types.Failure)

func (*DefaultReporter) EmitProgressReport added in v2.2.0

func (r *DefaultReporter) EmitProgressReport(report types.ProgressReport)

func (*DefaultReporter) EmitReportEntry added in v2.5.0

func (r *DefaultReporter) EmitReportEntry(entry types.ReportEntry)

func (*DefaultReporter) EmitSpecEvent added in v2.5.0

func (r *DefaultReporter) EmitSpecEvent(event types.SpecEvent)

func (*DefaultReporter) SuiteDidEnd

func (r *DefaultReporter) SuiteDidEnd(report types.Report)

func (*DefaultReporter) SuiteWillBegin

func (r *DefaultReporter) SuiteWillBegin(report types.Report)

func (*DefaultReporter) WillRun

func (r *DefaultReporter) WillRun(report types.SpecReport)

type DeprecatedReporter deprecated

type DeprecatedReporter interface {
	SuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary)
	BeforeSuiteDidRun(setupSummary *types.SetupSummary)
	SpecWillRun(specSummary *types.SpecSummary)
	SpecDidComplete(specSummary *types.SpecSummary)
	AfterSuiteDidRun(setupSummary *types.SetupSummary)
	SuiteDidEnd(summary *types.SuiteSummary)
}

Deprecated: DeprecatedReporter was how Ginkgo V1 provided support for CustomReporters this has been removed in V2. Please read the documentation at: https://onsi.github.io/ginkgo/MIGRATING_TO_V2#removed-custom-reporters for Ginkgo's new behavior and for a migration path.

type JUnitError

type JUnitError struct {
	//Message maps onto the panic/exception thrown - equivalent to SpecReport.Failure.ForwardedPanic - or to "interrupted"
	Message string `xml:"message,attr"`
	//Type is one of "panicked" or "interrupted"
	Type string `xml:"type,attr"`
	//Description maps onto the captured stack trace for a panic, or the failure message for an interrupt which will include the dump of running goroutines
	Description string `xml:",chardata"`
}

type JUnitFailure

type JUnitFailure struct {
	//Message maps onto the failure message - equivalent to SpecReport.Failure.Message
	Message string `xml:"message,attr"`
	//Type is "failed"
	Type string `xml:"type,attr"`
	//Description maps onto the location and stack trace of the failure
	Description string `xml:",chardata"`
}

type JUnitProperties

type JUnitProperties struct {
	Properties []JUnitProperty `xml:"property"`
}

func (JUnitProperties) WithName

func (jup JUnitProperties) WithName(name string) string

type JUnitProperty

type JUnitProperty struct {
	Name  string `xml:"name,attr"`
	Value string `xml:"value,attr"`
}

type JUnitReporter

type JUnitReporter struct{}

Deprecated JUnitReporter (so folks can still compile their suites)

func NewJUnitReporter

func NewJUnitReporter(_ string) *JUnitReporter

func (*JUnitReporter) AfterSuiteDidRun

func (reporter *JUnitReporter) AfterSuiteDidRun(_ *types.SetupSummary)

func (*JUnitReporter) BeforeSuiteDidRun

func (reporter *JUnitReporter) BeforeSuiteDidRun(_ *types.SetupSummary)

func (*JUnitReporter) SpecDidComplete

func (reporter *JUnitReporter) SpecDidComplete(_ *types.SpecSummary)

func (*JUnitReporter) SpecWillRun

func (reporter *JUnitReporter) SpecWillRun(_ *types.SpecSummary)

func (*JUnitReporter) SuiteDidEnd

func (reporter *JUnitReporter) SuiteDidEnd(_ *types.SuiteSummary)

func (*JUnitReporter) SuiteWillBegin

func (reporter *JUnitReporter) SuiteWillBegin(_ config.GinkgoConfigType, _ *types.SuiteSummary)

type JUnitSkipped

type JUnitSkipped struct {
	// Message maps onto "pending" if the test was marked pending, "skipped" if the test was marked skipped, and "skipped - REASON" if the user called Skip(REASON)
	Message string `xml:"message,attr"`
}

type JUnitTestCase

type JUnitTestCase struct {
	// Name maps onto the full text of the spec - equivalent to "[SpecReport.LeafNodeType] SpecReport.FullText()"
	Name string `xml:"name,attr"`
	// Classname maps onto the name of the test suite - equivalent to Report.SuiteDescription
	Classname string `xml:"classname,attr"`
	// Status maps onto the string representation of SpecReport.State
	Status string `xml:"status,attr"`
	// Time is the time in seconds to execute the spec - maps onto SpecReport.RunTime
	Time float64 `xml:"time,attr"`
	// Owner is the owner the spec - is set if a label matching Label("owner:X") is provided.  The last matching label is used as the owner, thereby allowing specs to override owners specified in container nodes.
	Owner string `xml:"owner,attr,omitempty"`
	//Skipped is populated with a message if the test was skipped or pending
	Skipped *JUnitSkipped `xml:"skipped,omitempty"`
	//Error is populated if the test panicked or was interrupted
	Error *JUnitError `xml:"error,omitempty"`
	//Failure is populated if the test failed
	Failure *JUnitFailure `xml:"failure,omitempty"`
	//SystemOut maps onto any captured stdout/stderr output - maps onto SpecReport.CapturedStdOutErr
	SystemOut string `xml:"system-out,omitempty"`
	//SystemOut maps onto any captured GinkgoWriter output - maps onto SpecReport.CapturedGinkgoWriterOutput
	SystemErr string `xml:"system-err,omitempty"`
}

type JUnitTestSuite

type JUnitTestSuite struct {
	// Name maps onto the description of the test suite - maps onto Report.SuiteDescription
	Name string `xml:"name,attr"`
	// Package maps onto the absolute path to the test suite - maps onto Report.SuitePath
	Package string `xml:"package,attr"`
	// Tests maps onto the total number of specs in the test suite (this includes any suite nodes such as BeforeSuite)
	Tests int `xml:"tests,attr"`
	// Disabled maps onto specs that are pending
	Disabled int `xml:"disabled,attr"`
	// Skiped maps onto specs that are skipped
	Skipped int `xml:"skipped,attr"`
	// Errors maps onto specs that panicked or were interrupted
	Errors int `xml:"errors,attr"`
	// Failures maps onto specs that failed
	Failures int `xml:"failures,attr"`
	// Time is the time in seconds to execute all the test suite - maps onto Report.RunTime
	Time float64 `xml:"time,attr"`
	// Timestamp is the ISO 8601 formatted start-time of the suite - maps onto Report.StartTime
	Timestamp string `xml:"timestamp,attr"`

	//Properties captures the information stored in the rest of the Report type (including SuiteConfig) as key-value pairs
	Properties JUnitProperties `xml:"properties"`

	//TestCases capture the individual specs
	TestCases []JUnitTestCase `xml:"testcase"`
}

type JUnitTestSuites

type JUnitTestSuites struct {
	XMLName xml.Name `xml:"testsuites"`
	// Tests maps onto the total number of specs in all test suites (this includes any suite nodes such as BeforeSuite)
	Tests int `xml:"tests,attr"`
	// Disabled maps onto specs that are pending and/or skipped
	Disabled int `xml:"disabled,attr"`
	// Errors maps onto specs that panicked or were interrupted
	Errors int `xml:"errors,attr"`
	// Failures maps onto specs that failed
	Failures int `xml:"failures,attr"`
	// Time is the time in seconds to execute all test suites
	Time float64 `xml:"time,attr"`

	//The set of all test suites
	TestSuites []JUnitTestSuite `xml:"testsuite"`
}

type JunitReportConfig added in v2.5.0

type JunitReportConfig struct {
	// Spec States for which no timeline should be emitted for system-err
	// set this to types.SpecStatePassed|types.SpecStateSkipped|types.SpecStatePending to only match failing specs
	OmitTimelinesForSpecState types.SpecState

	// Enable OmitFailureMessageAttr to prevent failure messages appearing in the "message" attribute of the Failure and Error tags
	OmitFailureMessageAttr bool

	//Enable OmitCapturedStdOutErr to prevent captured stdout/stderr appearing in system-out
	OmitCapturedStdOutErr bool

	// Enable OmitSpecLabels to prevent labels from appearing in the spec name
	OmitSpecLabels bool

	// Enable OmitLeafNodeType to prevent the spec leaf node type from appearing in the spec name
	OmitLeafNodeType bool

	// Enable OmitSuiteSetupNodes to prevent the creation of testcase entries for setup nodes
	OmitSuiteSetupNodes bool
}

type NoopReporter

type NoopReporter struct{}

func (NoopReporter) DidRun

func (n NoopReporter) DidRun(report types.SpecReport)

func (NoopReporter) EmitFailure added in v2.5.0

func (n NoopReporter) EmitFailure(state types.SpecState, failure types.Failure)

func (NoopReporter) EmitProgressReport added in v2.2.0

func (n NoopReporter) EmitProgressReport(progressReport types.ProgressReport)

func (NoopReporter) EmitReportEntry added in v2.5.0

func (n NoopReporter) EmitReportEntry(entry types.ReportEntry)

func (NoopReporter) EmitSpecEvent added in v2.5.0

func (n NoopReporter) EmitSpecEvent(event types.SpecEvent)

func (NoopReporter) SuiteDidEnd

func (n NoopReporter) SuiteDidEnd(report types.Report)

func (NoopReporter) SuiteWillBegin

func (n NoopReporter) SuiteWillBegin(report types.Report)

func (NoopReporter) WillRun

func (n NoopReporter) WillRun(report types.SpecReport)

type Reporter

type Reporter interface {
	SuiteWillBegin(report types.Report)
	WillRun(report types.SpecReport)
	DidRun(report types.SpecReport)
	SuiteDidEnd(report types.Report)

	//Timeline emission
	EmitFailure(state types.SpecState, failure types.Failure)
	EmitProgressReport(progressReport types.ProgressReport)
	EmitReportEntry(entry types.ReportEntry)
	EmitSpecEvent(event types.SpecEvent)
}

Jump to

Keyboard shortcuts

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