...

Package reporters

import "github.com/onsi/ginkgo/v2/reporters"
Overview
Index

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 ▾

func GenerateJSONReport(report types.Report, destination string) error
func GenerateJUnitReport(report types.Report, dst string) error
func GenerateJUnitReportWithConfig(report types.Report, dst string, config JunitReportConfig) error
func GenerateTeamcityReport(report types.Report, dst string) error
func MergeAndCleanupJSONReports(sources []string, destination string) ([]string, error)
func MergeAndCleanupJUnitReports(sources []string, dst string) ([]string, error)
func MergeAndCleanupTeamcityReports(sources []string, dst string) ([]string, error)
func RenderTimeline(spec types.SpecReport, noColor bool) string
func ReportViaDeprecatedReporter(reporter DeprecatedReporter, report types.Report)
type DefaultReporter
    func NewDefaultReporter(conf types.ReporterConfig, writer io.Writer) *DefaultReporter
    func NewDefaultReporterUnderTest(conf types.ReporterConfig, writer io.Writer) *DefaultReporter
    func (r *DefaultReporter) DidRun(report types.SpecReport)
    func (r *DefaultReporter) EmitFailure(state types.SpecState, failure types.Failure)
    func (r *DefaultReporter) EmitProgressReport(report types.ProgressReport)
    func (r *DefaultReporter) EmitReportEntry(entry types.ReportEntry)
    func (r *DefaultReporter) EmitSpecEvent(event types.SpecEvent)
    func (r *DefaultReporter) SuiteDidEnd(report types.Report)
    func (r *DefaultReporter) SuiteWillBegin(report types.Report)
    func (r *DefaultReporter) WillRun(report types.SpecReport)
type DeprecatedReporter
type JUnitError
type JUnitFailure
type JUnitProperties
    func (jup JUnitProperties) WithName(name string) string
type JUnitProperty
type JUnitReporter
    func NewJUnitReporter(_ string) *JUnitReporter
    func (reporter *JUnitReporter) AfterSuiteDidRun(_ *types.SetupSummary)
    func (reporter *JUnitReporter) BeforeSuiteDidRun(_ *types.SetupSummary)
    func (reporter *JUnitReporter) SpecDidComplete(_ *types.SpecSummary)
    func (reporter *JUnitReporter) SpecWillRun(_ *types.SpecSummary)
    func (reporter *JUnitReporter) SuiteDidEnd(_ *types.SuiteSummary)
    func (reporter *JUnitReporter) SuiteWillBegin(_ config.GinkgoConfigType, _ *types.SuiteSummary)
type JUnitSkipped
type JUnitTestCase
type JUnitTestSuite
type JUnitTestSuites
type JunitReportConfig
type NoopReporter
    func (n NoopReporter) DidRun(report types.SpecReport)
    func (n NoopReporter) EmitFailure(state types.SpecState, failure types.Failure)
    func (n NoopReporter) EmitProgressReport(progressReport types.ProgressReport)
    func (n NoopReporter) EmitReportEntry(entry types.ReportEntry)
    func (n NoopReporter) EmitSpecEvent(event types.SpecEvent)
    func (n NoopReporter) SuiteDidEnd(report types.Report)
    func (n NoopReporter) SuiteWillBegin(report types.Report)
    func (n NoopReporter) WillRun(report types.SpecReport)
type Reporter

Package files

default_reporter.go deprecated_reporter.go json_report.go junit_report.go reporter.go teamcity_report.go

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

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

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

func ReportViaDeprecatedReporter

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.

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

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

func (*DefaultReporter) EmitProgressReport

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

func (*DefaultReporter) EmitReportEntry

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

func (*DefaultReporter) EmitSpecEvent

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: 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 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)
}

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

Deprecated JUnitReporter (so folks can still compile their suites)

type JUnitReporter struct{}

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

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

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

func (NoopReporter) EmitProgressReport

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

func (NoopReporter) EmitReportEntry

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

func (NoopReporter) EmitSpecEvent

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)
}