Documentation
¶
Overview ¶
Package xunit defines types and utility functions in order to generate XML reports. The reports comply with the JUnit XML schema defined at: https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Error ¶
type Error struct {
XMLName xml.Name `xml:"error"`
Message string `xml:"message,attr,omitempty"`
Text string `xml:",chardata"`
}
Error encapsulates metadata regarding a test error.
type Report ¶
type Report struct {
XMLName xml.Name `xml:"testsuites"`
Name string `xml:"name,attr"`
TestCount int `xml:"tests,attr"`
ErrorCount int `xml:"errors,attr"`
TimeInSeconds float64 `xml:"time,attr"`
Suites []*TestSuite `xml:"testsuite"`
}
Report encapsulates the data for a xUnit XML report.
func (*Report) Finalize ¶
func (r *Report) Finalize()
Finalize iterates over the document object model and recomputes the counter values for parent objects. This ensures, for instance, that the errors attribute of a test suite specifies the correct sum of errors from its child test cases. This method should be called once all test cases are complete.
func (*Report) WriteToStream ¶
func (r *Report) WriteToStream(w io.Writer, opts ReportWritingOptions) error
WriteToStream accepts any io.Writer and writes the contents of the report to the stream. It accepts a ReportWritingOptions instance, which provides additional granularity for tweaking the output. The method r.Finalize() should be called before writing the report.
type ReportWritingOptions ¶
type ReportWritingOptions struct {
// Number of spaces which should be used for indentation.
IndentSize int
// Number of times to retry if writing to a stream fails and no progress is
// being made on each retry.
MaxRetries int
}
ReportWritingOptions wraps optional settings for the output report.
type TestCase ¶
type TestCase struct {
XMLName xml.Name `xml:"testcase"`
Name string `xml:"name,attr"`
TimeInSeconds float64 `xml:"time,attr"`
Errors []*Error `xml:"error"`
}
TestCase encapsulates metadata regarding a single test.
type TestSuite ¶
type TestSuite struct {
XMLName xml.Name `xml:"testsuite"`
ID string `xml:"id,attr"`
Name string `xml:"name,attr"`
TestCount int `xml:"tests,attr"`
ErrorCount int `xml:"errors,attr"`
TimeInSeconds float64 `xml:"time,attr"`
Cases []*TestCase `xml:"testcase"`
}
TestSuite encapsulates metadata for a collection of test cases.