junit

package
v2.0.0-...-bf43703 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package junit defines a JUnit XML report and includes convenience methods for working with these reports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Output

type Output struct {
	Data string `xml:"data"`
}

Output represents output written to stdout or sderr.

type Property

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

Property represents a key/value pair.

type Result

type Result struct {
	Message string `xml:"message,attr"`
	Type    string `xml:"type,attr,omitempty"`
	Data    string `xml:"data"`
}

Result represents the result of a single test.

type Testcase

type Testcase struct {
	// required attributes
	Name      string `xml:"name,attr"`
	Classname string `xml:"classname,attr"`

	// optional attributes
	Time   string `xml:"time,attr,omitempty"` // duration in seconds
	Status string `xml:"status,attr,omitempty"`

	Skipped   *Result `xml:"skipped,omitempty"`
	Error     *Result `xml:"error,omitempty"`
	Failure   *Result `xml:"failure,omitempty"`
	SystemOut *Output `xml:"system-out,omitempty"`
	SystemErr *Output `xml:"system-err,omitempty"`
}

Testcase represents a single test with its results.

type Testsuite

type Testsuite struct {
	// required attributes
	Name     string `xml:"name,attr"`
	Tests    int    `xml:"tests,attr"`
	Failures int    `xml:"failures,attr"`
	Errors   int    `xml:"errors,attr"`
	ID       int    `xml:"id,attr"`

	// optional attributes
	Disabled  int    `xml:"disabled,attr,omitempty"`
	Hostname  string `xml:"hostname,attr,omitempty"`
	Package   string `xml:"package,attr,omitempty"`
	Skipped   int    `xml:"skipped,attr,omitempty"`
	Time      string `xml:"time,attr"`                // duration in seconds
	Timestamp string `xml:"timestamp,attr,omitempty"` // date and time in ISO8601
	File      string `xml:"file,attr,omitempty"`

	Properties *[]Property `xml:"properties>property,omitempty"`
	Testcases  []Testcase  `xml:"testcase,omitempty"`
	SystemOut  *Output     `xml:"system-out,omitempty"`
	SystemErr  *Output     `xml:"system-err,omitempty"`
}

Testsuite is a single JUnit testsuite containing testcases.

func (*Testsuite) AddProperty

func (t *Testsuite) AddProperty(name, value string)

AddProperty adds a property with the given name and value to this Testsuite.

func (*Testsuite) AddTestcase

func (t *Testsuite) AddTestcase(tc Testcase)

AddTestcase adds Testcase tc to this Testsuite.

func (*Testsuite) SetTimestamp

func (t *Testsuite) SetTimestamp(timestamp time.Time)

SetTimestamp sets the timestamp in this Testsuite.

type Testsuites

type Testsuites struct {
	XMLName xml.Name `xml:"testsuites"`

	Name     string `xml:"name,attr,omitempty"`
	Time     string `xml:"time,attr,omitempty"` // total duration in seconds
	Tests    int    `xml:"tests,attr,omitempty"`
	Errors   int    `xml:"errors,attr,omitempty"`
	Failures int    `xml:"failures,attr,omitempty"`
	Skipped  int    `xml:"skipped,attr,omitempty"`
	Disabled int    `xml:"disabled,attr,omitempty"`

	Suites []Testsuite `xml:"testsuite,omitempty"`
}

Testsuites is a collection of JUnit testsuites.

func CreateFromReport

func CreateFromReport(report gtr.Report, hostname string) Testsuites

CreateFromReport creates a JUnit representation of the given gtr.Report.

func (*Testsuites) AddSuite

func (t *Testsuites) AddSuite(ts Testsuite)

AddSuite adds a Testsuite and updates this testssuites' totals.

Jump to

Keyboard shortcuts

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