report

package
v0.1.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveReport

func SaveReport(report *TestsReport, serializer ReportSerializer, filePath string) error

Types

type Failure

type Failure struct {
	// Message provides a summary of the failure.
	Message string `json:"message" xml:"message,attr"`
}

Failure represents details of a test failure.

type JSONSerializer

type JSONSerializer struct{}

func (JSONSerializer) Serialize

func (s JSONSerializer) Serialize(report *TestsReport) ([]byte, error)

type OperationReport

type OperationReport struct {
	// Name of the operation.
	Name string `json:"name" xml:"name,attr"`
	// TimeStamp marks when the operation began execution.
	TimeStamp time.Time `json:"timestamp" xml:"timestamp,attr"`
	// Time indicates the total duration of the operation.
	Time string `json:"time" xml:"time,attr"`
	// Result of the operation.
	Result string `json:"result" xml:"result,attr"`
	// Message provides additional information about the operation's outcome.
	Message string `json:"message,omitempty" xml:"message,omitempty"`
	// Type indicates the type of operation.
	OperationType OperationType `json:"operationType,omitempty" xml:"operationType,attr"`
}

OperationReport details the outcome of a single operation within a test step.

func NewOperation

func NewOperation(name string, operationType OperationType) *OperationReport

NewOperation creates a new OperationReport with the given details.

func (*OperationReport) MarkOperationEnd

func (op *OperationReport) MarkOperationEnd(success bool, message string)

MarkOperationEnd marks the end time of an OperationReport and calculates its duration.

type OperationType

type OperationType string
const (
	OperationTypeCreate  OperationType = "create"
	OperationTypeDelete  OperationType = "delete"
	OperationTypeApply   OperationType = "apply"
	OperationTypeAssert  OperationType = "assert"
	OperationTypeError   OperationType = "error"
	OperationTypeScript  OperationType = "script"
	OperationTypeSleep   OperationType = "sleep"
	OperationTypeCommand OperationType = "command"
)

type ReportSerializer

type ReportSerializer interface {
	Serialize(report *TestsReport) ([]byte, error)
}

func GetSerializer

func GetSerializer(format v1alpha1.ReportFormatType) (ReportSerializer, error)

type TestReport

type TestReport struct {
	// Name of the test.
	Name string `json:"name" xml:"name,attr"`
	// TimeStamp marks when the test began execution.
	TimeStamp time.Time `json:"timestamp" xml:"timestamp,attr"`
	// Time indicates the total duration of the test.
	Time string `json:"time" xml:"time,attr"`
	// Failure captures details if the test failed it should be nil otherwise.
	Failure *Failure `json:"failure,omitempty" xml:"failure,omitempty"`
	// Test count the number of tests in the suite/TestReport.
	Test int `json:"tests" xml:"tests,attr"`
	// Spec represents the specifications of the test.
	Steps []*TestSpecStepReport `json:"testcase,omitempty" xml:"testcase,omitempty"`
	// Concurrent indicates if the test runs concurrently with other tests.
	Concurrent bool `json:"concurrent,omitempty" xml:"concurrent,attr,omitempty"`
	// Namespace in which the test runs.
	Namespace string `json:"namespace,omitempty" xml:"namespace,attr,omitempty"`
	// Skip indicates if the test is skipped.
	Skip bool `json:"skip,omitempty" xml:"skip,attr,omitempty"`
	// SkipDelete indicates if resources are not deleted after test execution.
	SkipDelete bool `json:"skipDelete,omitempty" xml:"skipDelete,attr,omitempty"`
}

TestReport represents a report for a single test.

func NewTest

func NewTest(name string) *TestReport

NewTest creates a new TestReport with the given name.

func (*TestReport) AddTestStep

func (t *TestReport) AddTestStep(step *TestSpecStepReport)

AddTestStep adds a test step report to the TestReport.

func (*TestReport) MarkTestEnd

func (t *TestReport) MarkTestEnd()

MarkTestEnd marks the end time of a TestReport and calculates its duration.

func (*TestReport) NewFailure added in v0.0.7

func (t *TestReport) NewFailure(message string)

NewFailure creates a new Failure instance with the given message and type and assigns it to the TestReport.

type TestSpecStepReport

type TestSpecStepReport struct {
	// Name of the test step.
	Name string `json:"name,omitempty" xml:"name,attr,omitempty"`
	// Results are the outcomes of operations performed in this step.
	Results []*OperationReport `json:"results,omitempty" xml:"results,omitempty"`
}

TestSpecStepReport represents a report of a single step in a test.

func NewTestSpecStep

func NewTestSpecStep(name string) *TestSpecStepReport

NewTestSpecStep initializes a new TestSpecStepReport with the given name.

func (*TestSpecStepReport) AddOperation

func (ts *TestSpecStepReport) AddOperation(op *OperationReport)

AddOperation adds an operation report to the TestSpecStepReport.

type TestsReport

type TestsReport struct {
	// Name of the test suite.
	Name string `json:"name" xml:"name,attr"`
	// TimeStamp marks when the test suite began execution.
	TimeStamp time.Time `json:"timestamp" xml:"timestamp,attr"`
	// Time indicates the total duration of the test suite.
	Time string `json:"time" xml:"time,attr"`
	// Test count the number of tests in the files/TestReports.
	Test int `json:"tests" xml:"tests,attr"`
	// Reports is an array of individual test reports within this suite.
	Reports []*TestReport `json:"testsuite" xml:"testsuite"`
	// Failures count the number of failed tests in the suite.
	Failures int `json:"failures" xml:"failures,attr"`
}

TestsReport encapsulates the entire report for a test suite.

func NewTests

func NewTests(name string) *TestsReport

NewTests initializes a new TestsReport with the given name.

func (*TestsReport) AddTest

func (tr *TestsReport) AddTest(test *TestReport)

AddTest adds a test report to the TestsReport.

func (*TestsReport) Close

func (tr *TestsReport) Close()

Close finalizes the TestsReport, marking its end time and calculating the overall duration.

func (*TestsReport) SaveReportBasedOnType

func (report *TestsReport) SaveReportBasedOnType(reportFormat v1alpha1.ReportFormatType, reportName string) error

type XMLSerializer

type XMLSerializer struct{}

func (XMLSerializer) Serialize

func (s XMLSerializer) Serialize(report *TestsReport) ([]byte, error)

Jump to

Keyboard shortcuts

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