report

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package report provides test result reporting functionality in various formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Failure

type Failure struct {
	// Text provides detailed information regarding failure.  It supports multi-line output.
	Text string `xml:",chardata" json:"text,omitempty"`
	// Message provides the summary of the failure.
	Message string `xml:"message,attr" json:"message"`
	Type    string `xml:"type,attr" json:"type,omitempty"`
}

Failure defines a test failure.

func NewFailure

func NewFailure(msg string, errs []error) *Failure

NewFailure returns the address of a newly created Failure

type Properties

type Properties struct {
	Property []Property `xml:"property" json:"property,omitempty"`
}

Properties defines the collection of properties.

type Property

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

Property are name/value pairs which can be provided in the report for things such as kuttl.version.

type StepReporter

type StepReporter interface {
	Failure(message string, errors ...error)
	AddAssertions(i int)
}

StepReporter is an interface for reporting status of a test step.

type TestReporter

type TestReporter interface {
	Step(stepName string) StepReporter
	Done()
}

TestReporter is an interface for reporting status of a test. For each step, call Step and use the returned step reporter. Make sure to call Done when a test ends (preferably using defer).

type Testcase

type Testcase struct {
	// Classname is a junit thing, for kuttl it is the testsuite name.
	Classname string `xml:"classname,attr" json:"classname"`
	// Name is the name of the test (folder of test if not redefined by the TestStep).
	Name string `xml:"name,attr" json:"name"`
	// Timestamp is the time when this Testcase started.
	// This attribute is not in the mentioned XML schema (unlike Testsuite.Timestamp) but should be
	// gracefully ignored by readers who do not expect it.
	Timestamp time.Time `xml:"timestamp,attr" json:"timestamp"`
	// Time is the elapsed time of the test (and all of its steps).
	Time string `xml:"time,attr" json:"time"`
	// Assertions is the number of asserts and errors defined in the test.
	Assertions int `xml:"assertions,attr" json:"assertions,omitempty"`
	// Failure defines a failure in this Testcase.
	Failure *Failure `xml:"failure" json:"failure,omitempty"`
	// contains filtered or unexported fields
}

Testcase is the finest grain level of reporting, it is the kuttl test (which contains steps).

func NewCase

func NewCase(name string) *Testcase

NewCase returns the address of a newly create Testcase

type Testsuite

type Testsuite struct {
	// Tests is the number of Testcases in the collection.
	Tests int `xml:"tests,attr" json:"tests"`
	// Failures is the summary number of all failure in the collection testcases.
	Failures int `xml:"failures,attr" json:"failures"`
	// Timestamp is the time when this Testsuite started.
	Timestamp time.Time `xml:"timestamp,attr" json:"timestamp"`
	// Time is the duration of time for this Testsuite, this is tricky as tests run concurrently.
	// This is the elapse time between the start of the testsuite and the end of the latest testcase in the collection.
	Time string `xml:"time,attr" json:"time"`
	// Name is the kuttl test name.
	Name string `xml:"name,attr" json:"name"`
	// Properties which are specific to this suite.
	Properties *Properties `xml:"properties" json:"properties,omitempty"`
	// Testcases is a collection of test cases.
	Testcases []*Testcase `xml:"testcase" json:"testcase,omitempty"`
	// SubSuites is a collection of child test suites.
	SubSuites []*Testsuite `xml:"testsuite" json:"testsuite,omitempty"`
	// contains filtered or unexported fields
}

Testsuite is a collection of Testcase and is a summary of those details.

func NewSuite

func NewSuite(name string, reportGranularity string) *Testsuite

NewSuite returns the address of a newly created TestSuite

func (*Testsuite) AddProperty

func (ts *Testsuite) AddProperty(property Property)

AddProperty adds a property to a testsuite

func (*Testsuite) AddTestcase

func (ts *Testsuite) AddTestcase(testcase *Testcase)

AddTestcase adds a testcase to a suite, providing stats and calculations to both

func (*Testsuite) NewSubSuite

func (ts *Testsuite) NewSubSuite(name string) *Testsuite

NewSubSuite creates a new child suite and returns it.

func (*Testsuite) NewTestReporter

func (ts *Testsuite) NewTestReporter(name string) TestReporter

NewTestReporter creates a new test reporter based on the configured granularity.

type Testsuites

type Testsuites struct {
	// XMLName is required to refine the name (or case of the name) in the root xml element.  Otherwise it adds no value and is ignored for json output.
	XMLName xml.Name `json:"-"`
	// Name is the name of the full set of tests which is possible to set in kuttl but is rarely used :)
	Name string `xml:"name,attr" json:"name"`
	// Tests is a summary value of the total number of tests for all testsuites.
	Tests int `xml:"tests,attr" json:"tests"`
	// Failures is a summary value of the total number of failures for all testsuites.
	Failures int `xml:"failures,attr" json:"failures"`
	// Time is the elapsed time of the entire suite of tests.
	Time string `xml:"time,attr" json:"time"`
	// Properties which are for the entire set of tests.
	Properties *Properties `xml:"properties" json:"properties,omitempty"`
	// Testsuite is a collection of test suites.
	Testsuite []*Testsuite `xml:"testsuite" json:"testsuite,omitempty"`
	// Failure defines a failure in this Testsuites. Not part of the Junit XML report standard, however it is needed to
	// communicate test infra failures, such as failed auth, or connection issues.
	Failure *Failure `xml:"failure" json:"failure,omitempty"`
	// contains filtered or unexported fields
}

Testsuites is a collection of Testsuite and defines the rollup summary of all stats.

func NewSuiteCollection

func NewSuiteCollection(name string) *Testsuites

NewSuiteCollection returns the address of a newly created TestSuites

func (*Testsuites) AddProperty

func (ts *Testsuites) AddProperty(property Property)

AddProperty adds a property to a testsuites

func (*Testsuites) AddTestSuite

func (ts *Testsuites) AddTestSuite(testsuite *Testsuite)

AddTestSuite is a convenience method to add a testsuite to the collection in testsuites

func (*Testsuites) Close

func (ts *Testsuites) Close()

Close closes the report and does all end stat calculations

func (*Testsuites) Report

func (ts *Testsuites) Report(dir, name string, ftype Type) error

Report prints a report for TestSuites to the directory. ftype == json | xml

func (*Testsuites) SetFailure

func (ts *Testsuites) SetFailure(message string)

SetFailure adds a failure to the TestSuites collection for startup failures in the test harness

type Type

type Type string

Type defines the report.type of report to create.

const (
	// XML defines the xml Type.
	XML Type = "xml"
	// JSON defines the json Type.
	JSON Type = "json"
)

Jump to

Keyboard shortcuts

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