junit

package
v0.0.0-...-703489d Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Overview

Package junit is DEPRECATED. Please use github.com/jstemmer/go-junit-report as a library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateXMLErrorMsg

func CreateXMLErrorMsg(testSuite, testName, errMsg, dest string)

CreateXMLErrorMsg outputs a junit testsuite, testname and error message to the destination path in XML format

Types

type TestCase

type TestCase struct {
	Name       string          `xml:"name,attr"`
	Time       string          `xml:"time,attr"` // Seconds
	ClassName  string          `xml:"classname,attr"`
	Failure    *string         `xml:"failure,omitempty"`
	Output     *string         `xml:"system-out,omitempty"`
	Error      *string         `xml:"system-err,omitempty"`
	Skipped    *string         `xml:"skipped,omitempty"`
	Properties *TestProperties `xml:"properties,omitempty"`
}

TestCase holds <testcase/> results

func (*TestCase) AddProperty

func (testCase *TestCase) AddProperty(name, val string)

AddProperty adds property to testcase

func (*TestCase) GetTestStatus

func (testCase *TestCase) GetTestStatus() TestStatusEnum

GetTestStatus returns the test status as a string

type TestProperties

type TestProperties struct {
	Properties []TestProperty `xml:"property"`
}

TestProperties is an array of test properties

type TestProperty

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

TestProperty defines a property of the test

type TestStatusEnum

type TestStatusEnum string

TestStatusEnum is a enum for test result status

const (
	// Failed means junit test failed
	Failed TestStatusEnum = "failed"
	// Skipped means junit test skipped
	Skipped TestStatusEnum = "skipped"
	// Passed means junit test passed
	Passed TestStatusEnum = "passed"
)

type TestSuite

type TestSuite struct {
	XMLName    xml.Name       `xml:"testsuite"`
	Name       string         `xml:"name,attr"`
	Time       string         `xml:"time,attr"` // Seconds
	Failures   int            `xml:"failures,attr"`
	Tests      int            `xml:"tests,attr"`
	TestCases  []TestCase     `xml:"testcase"`
	Properties TestProperties `xml:"properties"`
}

TestSuite holds <testSuite/> results

func (*TestSuite) AddTestCase

func (ts *TestSuite) AddTestCase(tc TestCase)

AddTestCase adds a testcase to the testsuite

type TestSuites

type TestSuites struct {
	XMLName xml.Name    `xml:"testsuites"`
	Suites  []TestSuite `xml:"testsuite"`
}

TestSuites holds a <testSuites/> list of TestSuite results

func UnMarshal

func UnMarshal(buf []byte) (*TestSuites, error)

UnMarshal converts bytes array to TestSuites struct, it works with both TestSuites and TestSuite structs, if input is a TestSuite struct it will still return a TestSuites struct, which is an empty wrapper TestSuites containing only the input Suite

func (*TestSuites) AddTestSuite

func (testSuites *TestSuites) AddTestSuite(testSuite *TestSuite) error

AddTestSuite adds TestSuite to TestSuites

func (*TestSuites) GetTestSuite

func (testSuites *TestSuites) GetTestSuite(suiteName string) (*TestSuite, error)

GetTestSuite gets TestSuite struct by name

func (*TestSuites) ToBytes

func (testSuites *TestSuites) ToBytes(prefix, indent string) ([]byte, error)

ToBytes converts TestSuites struct to bytes array

Jump to

Keyboard shortcuts

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