report

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: MIT Imports: 12 Imported by: 1

Documentation

Overview

Package report defines allure reporting structures.

Index

Constants

View Source
const (
	Broken  = Status("broken")
	Passed  = Status("passed")
	Failed  = Status("failed")
	Skipped = Status("skipped")
	Unknown = Status("unknown")
)

Available statuses.

View Source
const (
	// CSVMime is a media type.
	CSVMime = "text/csv"
)

Variables

This section is empty.

Functions

func MediaType

func MediaType(t string) string

MediaType returns MIME type for allure type.

Types

type Attachment

type Attachment struct {
	Name   string `json:"name"`
	Source string `json:"source"`
	Type   string `json:"type"`
}

Attachment can be attached.

func NewAttachment

func NewAttachment(name string, mimeType string, resultsPath string, content []byte) (*Attachment, error)

NewAttachment creates and stores attachment.

type Container

type Container struct {
	UUID     string      `json:"uuid,omitempty"`
	Name     string      `json:"name"`
	Children []string    `json:"children"`
	Start    TimestampMs `json:"start,omitempty"`
	Stop     TimestampMs `json:"stop,omitempty"`
}

Container lists all results.

type Executor

type Executor struct {
	Name string `json:"name,omitempty" example:"Jenkins"`
	// Type may be one of [github, gitlab, teamcity, bamboo, jenkins] or a custom one.
	Type       string `json:"type,omitempty" example:"jenkins"`
	URL        string `json:"url,omitempty" example:"url"`
	BuildOrder int    `json:"buildOrder,omitempty" example:"13"`
	BuildName  string `json:"buildName,omitempty" example:"allure-report_deploy#13"`
	BuildURL   string `json:"buildUrl,omitempty" example:"http://example.org/build#13"`
	ReportURL  string `json:"reportUrl,omitempty" example:"http://example.org/build#13/AllureReport"`
	ReportName string `json:"reportName,omitempty" example:"Demo allure report"`
}

Executor describes execution context.

type Formatter

type Formatter struct {
	Container   *Container
	Res         *Result
	LastTime    TimestampMs
	ResultsPath string
	// contains filtered or unexported fields
}

Formatter writes test results as Allure report.

func (*Formatter) BytesAttachment

func (f *Formatter) BytesAttachment(content []byte, mediaType string) (*Attachment, error)

BytesAttachment creates scalar attachment.

func (*Formatter) Finish

func (f *Formatter) Finish(exec Executor)

Finish flushes collected results.

func (*Formatter) Init

func (f *Formatter) Init() error

Init prepares results directory.

func (*Formatter) StartNewResult

func (f *Formatter) StartNewResult(res Result)

StartNewResult finishes previous Result and starts new.

func (*Formatter) StepFinished

func (f *Formatter) StepFinished(name string, status Status, statusDetails *StatusDetails, prepareStep func(s *Step))

StepFinished finishes step and updates result.

func (*Formatter) TableAttachment

func (f *Formatter) TableAttachment(table [][]string) (*Attachment, error)

TableAttachment creates table attachment.

func (*Formatter) WriteJSON

func (f *Formatter) WriteJSON(name string, v interface{})

WriteJSON writes named value as JSON result.

func (*Formatter) WriteResult

func (f *Formatter) WriteResult(r *Result)

WriteResult writes single result.

type Label

type Label struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

Label is a named value.

type Link struct {
	Name string   `json:"name,omitempty"`
	Type LinkType `json:"type,omitempty"`
	URL  string   `json:"url,omitempty"`
}

Link references additional resources.

type LinkType

type LinkType string

LinkType is a type of link.

const (
	Issue  LinkType = "issue"
	TMS    LinkType = "tms"
	Custom LinkType = "custom"
)

Types of links.

type Parameter

type Parameter struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

Parameter is a named value.

type Result

type Result struct {
	UUID          string         `json:"uuid,omitempty"`
	HistoryID     string         `json:"historyId,omitempty"`
	Name          string         `json:"name,omitempty"`
	Description   string         `json:"description,omitempty"`
	Status        Status         `json:"status,omitempty"`
	StatusDetails *StatusDetails `json:"statusDetails,omitempty"`
	Stage         string         `json:"stage,omitempty"` // "finished"
	Steps         []Step         `json:"steps,omitempty"`
	Attachments   []Attachment   `json:"attachments,omitempty"`
	Parameters    []Parameter    `json:"parameters,omitempty"`
	Start         TimestampMs    `json:"start,omitempty"`
	Stop          TimestampMs    `json:"stop,omitempty"`
	Children      []string       `json:"children,omitempty"`
	FullName      string         `json:"fullName,omitempty"`
	Labels        []Label        `json:"labels,omitempty"`
	Links         []Link         `json:"links,omitempty"`
}

Result is the top level report object for a test.

18 known properties: "start", "descriptionHtml", "parameters", "name", "historyId", "statusDetails", "status", "links", "fullName", "uuid", "description", "testCaseId", "stage", "labels", "stop", "steps", "rerunOf", "attachments".

type Status

type Status string

Status describes test result.

type StatusDetails

type StatusDetails struct {
	Known   bool   `json:"known,omitempty"`
	Muted   bool   `json:"muted,omitempty"`
	Flaky   bool   `json:"flaky,omitempty"`
	Message string `json:"message,omitempty"`
	Trace   string `json:"trace,omitempty"`
}

StatusDetails provides additional information on status.

type Step

type Step struct {
	Name          string         `json:"name,omitempty"`
	Status        Status         `json:"status,omitempty"`
	StatusDetails *StatusDetails `json:"statusDetails,omitempty"`
	Stage         string         `json:"stage"`
	ChildrenSteps []Step         `json:"steps,omitempty"`
	Attachments   []Attachment   `json:"attachments,omitempty"`
	Parameters    []Parameter    `json:"parameters,omitempty"`
	Start         TimestampMs    `json:"start"`
	Stop          TimestampMs    `json:"stop"`
}

Step is a part of scenario result.

func StepFinished added in v0.2.1

func StepFinished(res *Result, name string, status Status, statusDetails *StatusDetails, prepareStep func(s *Step), start TimestampMs) Step

StepFinished updates result with a finished step.

type TimestampMs

type TimestampMs int64

TimestampMs is a timestamp in milliseconds.

func GetTimestampMs

func GetTimestampMs() TimestampMs

GetTimestampMs returns current time.

func TimeMs

func TimeMs(t time.Time) TimestampMs

TimeMs returns current time.

Jump to

Keyboard shortcuts

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