report

package
v0.0.0-...-ece35c1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Message string `xml:"message,attr,omitempty"`
	Type    string `xml:"type,attr,omitempty"`
	Content string `xml:",chardata"`
}

Error corresponds to an error tag inside testcase and should be added every time an error happens during testing. A test case can have several errors. It has three fields: Message, Type, and Content. Message maps to the message optional attribute, which can take the error message. Type maps to the type optional attribute, which can take the error type, and Content maps to the tag's content text, which can be a detailed representation of the error, eg: message and stack trace.

func NewAnonymousError

func NewAnonymousError(content string) *Error

NewAnonymousError returns an Error with the given content, but no message and type

func NewError

func NewError(msg string, errorType string, content string) *Error

NewError returns an Error with the given message, type, and content

type Failure

type Failure struct {
	Message string `xml:"message,attr,omitempty"`
	Type    string `xml:"type,attr,omitempty"`
	Content string `xml:",chardata"`
}

Failure corresponds to a failure tag inside testcase and should be added every time a failure happens during testing. A test case can have several failures. It has three fields: Message, Type, and Content. Message maps to the message optional attribute, which can take the failure message. Type maps to the type optional attribute, which can take the failure type, and Content maps to the tag's content text, which can be a detailed representation of the failure, eg: message, class, and file.

func NewAnonymousFailure

func NewAnonymousFailure(content string) *Failure

NewAnonymousError returns a Failure with the given content, but no message and type

func NewFailure

func NewFailure(msg string, failureType string, content string) *Failure

NewFailure returns a Failure with the given message, type, and content

type TestCase

type TestCase struct {
	ID        string        `xml:"id,attr,omitempty"`
	Name      string        `xml:"name,attr,omitempty"`
	Time      time.Duration `xml:"time,attr,omitempty"`
	Classname string        `xml:"classname,attr,omitempty"`
	Content   string        `xml:",chardata"`
	Failures  []*Failure    `xml:"failure"`
	Errors    []*Error      `xml:"error"`
	// contains filtered or unexported fields
}

TestCase maps to a testcase tag which represents a test case. It has the following fields: ID: optional test case ID. Maps to the id attribute. The attribute is omitted if empty. If given, an ID must be unique in the test suite. Name: optional test case name. Maps to the name attribute. The attribute is omitted if empty. Time: optional duration of the test. Maps to the time attribute. Omitted if empty. Classname: optional name of the module beiong tested. Maps to the classname attribute. Omitted if empty. Content: optional text content of the test. Maps to the content of the tag. Failures: test failures. Each element maps to its own failure tag. Errors: test errors. Each element maps to its own error tag.

func NewAnonymousTestCase

func NewAnonymousTestCase() *TestCase

NewAnonymousTestCase returns an empty test case

func NewTestCase

func NewTestCase(id string, name string, classname string) *TestCase

NewTestCase returns a test case with the given id, name, and classname

func (*TestCase) AddError

func (testCase *TestCase) AddError(e *Error)

AddError adds an error to the test case

func (*TestCase) AddFailure

func (testCase *TestCase) AddFailure(f *Failure)

AddFailure adds a failure to the test case

func (*TestCase) End

func (testCase *TestCase) End()

End sets the test cases duration

func (*TestCase) SetContent

func (testCase *TestCase) SetContent(c string)

SetContent sets the test case content

func (*TestCase) Start

func (testCase *TestCase) Start()

Start sets the time the test started

type TestSuite

type TestSuite struct {
	ID        string        `xml:"id,attr,omitempty"`
	Name      string        `xml:"name,attr,omitempty"`
	Time      time.Duration `xml:"time,attr,omitempty"`
	Tests     int           `xml:"tests,attr"`
	Failures  int           `xml:"failures,attr"`
	Errors    int           `xml:"errors,attr"`
	TestCases []*TestCase   `xml:"testcase,omitempty"`
}

TestSuite maps to a testsuite tag which represents a set of test cases. It has the following fields: ID:optional test suite ID. Maps to the id attribute. The attribute is omitted if empty. If given, an ID must be unique in the test suites. Name: optional test suite name. Maps to the name attribute. The attribute is omitted if empty. Time: optional duration of the suite. Maps to the time attribute. Omitted if empty. This field is calculated automatically by Testsuites.MakeReport(). Tests: total amount of test cases in the suite. Maps to the tests attribute. This field is calculated automatically by Testsuites.MakeReport(). Failures: total amount of failures cases in the suite. Maps to the failures attribute. This field is calculated automatically by Testsuites.MakeReport(). Errors: total amount of errors in the suite. Maps to the errors attribute. This field is calculated automatically by Testsuites.MakeReport(). TestCases: test cases in the suite. Each element maps to its own testcase tag.

func NewAnonymousTestSuite

func NewAnonymousTestSuite() *TestSuite

NewAnonymousTestSuite returns a new empty TestSuite

func NewTestSuite

func NewTestSuite(id string, name string) *TestSuite

NewTestSuite returns a new TestSuite with the given id and name

func (*TestSuite) AddTestCase

func (suite *TestSuite) AddTestCase(testcase *TestCase) error

AddTestCase adds a TestCase to the suite. If the test case has an ID, it must be unique within the suite. If it isn't an error is returned.

func (*TestSuite) RemoveTestCase

func (suite *TestSuite) RemoveTestCase(id string)

RemoveTestCase removes a test case with the given id from the suite if it exists

type TestSuites

type TestSuites struct {
	XMLName    xml.Name      `xml:"testsuites"`
	ID         string        `xml:"id,attr,omitempty"`
	Name       string        `xml:"name,attr,omitempty"`
	Tests      int           `xml:"tests,attr"`
	Failures   int           `xml:"failures,attr"`
	Errors     int           `xml:"errors,attr"`
	Time       time.Duration `xml:"time,attr,omitempty"`
	TestSuites []*TestSuite  `xml:"testsuite,omitempty"`
}

TestSuites maps to a testsuites tag which represents a set of test suites. It has the following fields: ID: optional ID. Maps to the id attribute. The attribute is omitted if empty. Name: optional name. Maps to the name attribute. The attribute is omitted if empty. Tests: total amount of test cases. Maps to the tests attribute. This field is calculated automatically by Testsuites.MakeReport(). Failures: total amount of failures. Maps to the failures attribute. This field is calculated automatically by Testsuites.MakeReport(). Errors: total amount of errors. Maps to the errors attribute. This field is calculated automatically by Testsuites.MakeReport(). Time: optional duration of the test. Maps to the time attribute. Omitted if empty. TestSuites: test suites. Each element maps to its own testsuite tag.

func NewAnonymousTestSuites

func NewAnonymousTestSuites() *TestSuites

NewAnonymousTestSuites returns an empty TestSuites

func NewTestSuites

func NewTestSuites(id string, name string) *TestSuites

NewTestSuites creates a new TestSuites with the given id and name

func (*TestSuites) AddTestSuite

func (suites *TestSuites) AddTestSuite(suite *TestSuite) error

AddTestSuite add a TestSuite to the TestSuites. If the test suite has an ID, it must be unique within the suites. If it isn't an error is returned.

func (*TestSuites) MakeReport

func (suites *TestSuites) MakeReport() ([]byte, error)

MakeReport generates the report XML as a slice of bytes. It is useful for any output other than generating a file. For saving the report as a file you should use SaveReport instead. All values are automatically calculated when calling this method.

func (*TestSuites) RemoveTestSuite

func (suites *TestSuites) RemoveTestSuite(id string)

RemoveTestSuite removes a suite with the given id if it exists.

func (*TestSuites) SaveReport

func (suites *TestSuites) SaveReport(filename string) error

SaveReport saves the report XMl in the given file name with the 644 permission settings. All values are automatically calculated when calling this method.

Jump to

Keyboard shortcuts

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