Documentation
¶
Index ¶
- type Error
- type Failure
- type Skipped
- type SystemErr
- type SystemOut
- type TestCase
- func (tc *TestCase) Errored(message, errorType, content string)
- func (tc *TestCase) Failed(message, failureType, content string)
- func (tc *TestCase) SetFile(file string)
- func (tc *TestCase) SetSystemErr(content string)
- func (tc *TestCase) SetSystemOut(content string)
- func (tc *TestCase) SetTime(duration string)
- func (tc *TestCase) Skip(message string)
- type TestSuite
- func (ts *TestSuite) AddMessageError(file, message, description string)
- func (ts *TestSuite) AddMessageFailed(file, message, description string)
- func (ts *TestSuite) AddMessageOK(file, message, description string)
- func (ts *TestSuite) AddTestCase(name, classname string) *TestCase
- func (ts *TestSuite) UpdateCounts()
- type TestSuites
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 represents an errored test case.
type Failure ¶
type Failure struct {
Message string `xml:"message,attr,omitempty"`
Type string `xml:"type,attr,omitempty"`
Content string `xml:",chardata"`
}
Failure represents a failed test case.
type Skipped ¶
type Skipped struct {
Message string `xml:"message,attr,omitempty"`
}
Skipped represents a skipped test case.
type SystemErr ¶
type SystemErr struct {
Content string `xml:",chardata"`
}
SystemErr represents standard error.
type SystemOut ¶
type SystemOut struct {
Content string `xml:",chardata"`
}
SystemOut represents standard output.
type TestCase ¶
type TestCase struct {
XMLName xml.Name `xml:"testcase"`
Name string `xml:"name,attr"`
ClassName string `xml:"classname,attr"`
File string `xml:"file,attr,omitempty"`
Time string `xml:"time,attr,omitempty"`
Failure *Failure `xml:"failure,omitempty"`
Error *Error `xml:"error,omitempty"`
Skipped *Skipped `xml:"skipped,omitempty"`
SystemOut *SystemOut `xml:"system-out,omitempty"`
SystemErr *SystemErr `xml:"system-err,omitempty"`
}
TestCase represents a single test case.
func (*TestCase) SetSystemErr ¶
SetSystemErr sets the system-err content.
func (*TestCase) SetSystemOut ¶
SetSystemOut sets the system-out content.
type TestSuite ¶
type TestSuite struct {
XMLName xml.Name `xml:"testsuite"`
Name string `xml:"name,attr"`
Tests int `xml:"tests,attr"`
Failures int `xml:"failures,attr"`
Errors int `xml:"errors,attr"`
Time string `xml:"time,attr,omitempty"`
Timestamp string `xml:"timestamp,attr,omitempty"`
TestCases []*TestCase `xml:"testcase"`
}
TestSuite represents a test suite.
func (*TestSuite) AddMessageError ¶
AddMessageError adds an errored test case with a message and description. If a test case with the same file and message exists, it updates it to errored.
func (*TestSuite) AddMessageFailed ¶
AddMessageFailed adds a failing test case with a message and description. If a test case with the same file and message already exists, it updates it to failed.
func (*TestSuite) AddMessageOK ¶
AddMessageOK adds a passing test case with a message and description. If a test case with the same file and message already exists, it does nothing.
func (*TestSuite) AddTestCase ¶
AddTestCase adds a new test case to the suite.
func (*TestSuite) UpdateCounts ¶
func (ts *TestSuite) UpdateCounts()
UpdateCounts updates the failure and error counts for the suite. This should be called before marshaling if counts are not manually managed.
type TestSuites ¶
type TestSuites struct {
XMLName xml.Name `xml:"testsuites"`
TestSuites []*TestSuite `xml:"testsuite"`
}
TestSuites is the root element of the JUnit XML report.
func NewTestSuites ¶
func NewTestSuites() *TestSuites
NewTestSuites creates a new TestSuites object.
func (*TestSuites) AddSuite ¶
func (ts *TestSuites) AddSuite(name string) *TestSuite
AddSuite adds a new test suite to the report.
func (*TestSuites) GetOrCreateSuite ¶
func (ts *TestSuites) GetOrCreateSuite(name string) *TestSuite
GetOrCreateSuite returns an existing suite by name or creates a new one.
func (*TestSuites) Marshal ¶
func (ts *TestSuites) Marshal() ([]byte, error)
Marshal returns the XML encoding of the TestSuites.
func (*TestSuites) String ¶
func (ts *TestSuites) String() string
func (*TestSuites) UpdateCounts ¶
func (ts *TestSuites) UpdateCounts()
UpdateCounts updates the counts for all suites.
func (*TestSuites) Write ¶
func (ts *TestSuites) Write(fileName string) error
Write writes the XML report to a file. If fileName is empty, it checks the JUNIT_FILE environment variable.