Documentation
¶
Overview ¶
Package reporter provides test result reporters. It is intended to be used in scenarigo.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*testContext)
Option represents an option for test reporter.
func WithMaxParallel ¶
WithMaxParallel returns an option to set the number of parallel.
func WithVerboseLog ¶
func WithVerboseLog() Option
WithVerboseLog returns an option to enable verbose log.
func WithWriter ¶
WithWriter returns an option to set the writer.
type ReportLogs ¶
type Reporter ¶
type Reporter interface {
Name() string
Fail()
Failed() bool
FailNow()
Log(args ...interface{})
Logf(format string, args ...interface{})
Error(args ...interface{})
Errorf(format string, args ...interface{})
Fatal(args ...interface{})
Fatalf(format string, args ...interface{})
Skip(args ...interface{})
Skipf(format string, args ...interface{})
SkipNow()
Skipped() bool
Parallel()
Run(name string, f func(r Reporter)) bool
// contains filtered or unexported methods
}
A Reporter is something that can be used to report test results.
type ScenarioFileReport ¶
type ScenarioFileReport struct {
Name string `json:"name" xml:"name,attr,omitempty"`
Result TestResult `json:"result" xml:"-"`
Duration TestDuration `json:"duration" xml:"time,attr"`
Scenarios []ScenarioReport `json:"scenarios" xml:"testcase"`
}
ScenarioFileReport represents a result report of a test scenario file.
func (ScenarioFileReport) MarshalXML ¶
func (r ScenarioFileReport) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML implements xml.Marshaler interface.
type ScenarioReport ¶
type ScenarioReport struct {
Name string `json:"name"`
File string `json:"-"`
Result TestResult `json:"result"`
Duration TestDuration `json:"duration"`
Steps []StepReport `json:"steps"`
}
ScenarioReport represents a result report of a test scenario.
func (ScenarioReport) MarshalXML ¶
func (r ScenarioReport) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML implements xml.Marshaler interface.
type StepReport ¶
type StepReport struct {
Name string `json:"name"`
Result TestResult `json:"result"`
Duration TestDuration `json:"duration"`
Logs ReportLogs `json:"logs"`
SubSteps []SubStepReport `json:"subSteps,omitempty"`
}
StepReport represents a result report of a test scenario step.
type SubStepReport ¶
type SubStepReport struct {
Name string `json:"name"`
Result TestResult `json:"result"`
Duration TestDuration `json:"duration"`
Logs ReportLogs `json:"logs"`
SubSteps []SubStepReport `json:"subSteps,omitempty"`
}
SubStepReport represents a result report of a test scenario sub step.
type TestDuration ¶
TestDuration represents an elapsed time of a test.
func (TestDuration) MarshalJSON ¶
func (d TestDuration) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (TestDuration) MarshalXMLAttr ¶
MarshalYAML implements xml.Marshaler interface.
func (TestDuration) MarshalYAML ¶
func (d TestDuration) MarshalYAML() ([]byte, error)
MarshalYAML implements yaml.Marshaler interface.
func (*TestDuration) UnmarshalJSON ¶
func (d *TestDuration) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
func (*TestDuration) UnmarshalYAML ¶
func (d *TestDuration) UnmarshalYAML(b []byte) error
UnmarshalYAML implements yaml.Unmarshaler interface.
type TestReport ¶
type TestReport struct {
XMLName xml.Name `json:"-" xml:"testsuites"`
Name string `json:"name,omitempty" xml:"name,attr,omitempty"`
Result TestResult `json:"result" xml:"-"`
Files []ScenarioFileReport `json:"files" xml:"testsuite"`
}
TestReport represents a test result report. This struct can be marshalled as JUnit-like format XML.
b, err := xml.MarshalIndent(test.report, "", " ")
if err != nil {
panic(err)
}
fmt.Println(b)
func GenerateTestReport ¶
func GenerateTestReport(r Reporter) (*TestReport, error)
GenerateTestReport generates a test result report from r.
type TestResult ¶
type TestResult int
TestResult represents a test result.
const ( TestResultUndefined TestResult = iota TestResultPassed TestResultFailed TestResultSkipped )
func (TestResult) MarshalJSON ¶
func (r TestResult) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (TestResult) MarshalYAML ¶
func (r TestResult) MarshalYAML() ([]byte, error)
MarshalYAML implements yaml.Marshaler interface.
func (*TestResult) UnmarshalJSON ¶
func (r *TestResult) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
func (*TestResult) UnmarshalYAML ¶
func (r *TestResult) UnmarshalYAML(b []byte) error
UnmarshalYAML implements yaml.Unmarshaler interface.