Documentation
¶
Overview ¶
Package runner responsible for excute the test case
Index ¶
- func RunTestCase(testcase *testing.TestCase, dataContext interface{}, ctx context.Context) (output interface{}, err error)
- type FormatPrinter
- type LevelWriter
- type ReportRecord
- type ReportResult
- type ReportResultSlice
- type ReportResultWithTotal
- type ReportResultWriter
- type TestCaseRunner
- type TestReporter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FormatPrinter ¶ added in v0.0.9
type FormatPrinter interface {
Fprintf(w io.Writer, level, format string, a ...any) (n int, err error)
}
FormatPrinter represents a formart printer with level
type LevelWriter ¶ added in v0.0.9
LevelWriter represents a writer with level
func NewDefaultLevelWriter ¶ added in v0.0.9
func NewDefaultLevelWriter(level string, writer io.Writer) LevelWriter
NewDefaultLevelWriter creates a default LevelWriter instance
type ReportRecord ¶ added in v0.0.4
type ReportRecord struct {
Method string
API string
Body string
BeginTime time.Time
EndTime time.Time
Error error
}
ReportRecord represents the raw data of a HTTP request
func NewReportRecord ¶ added in v0.0.4
func NewReportRecord() *ReportRecord
NewReportRecord creates a record, and set the begin time to be now
func (*ReportRecord) Duration ¶ added in v0.0.4
func (r *ReportRecord) Duration() time.Duration
Duration returns the duration between begin and end time
func (*ReportRecord) ErrorCount ¶ added in v0.0.4
func (r *ReportRecord) ErrorCount() int
ErrorCount returns the count number of errors
type ReportResult ¶ added in v0.0.4
type ReportResult struct {
API string
Count int
Average time.Duration
Max time.Duration
Min time.Duration
QPS int
Error int
}
ReportResult represents the report result of a set of the same API requests
type ReportResultSlice ¶ added in v0.0.4
type ReportResultSlice []ReportResult
ReportResultSlice is the alias type of ReportResult slice
func (ReportResultSlice) Len ¶ added in v0.0.4
func (r ReportResultSlice) Len() int
Len returns the count of slice items
func (ReportResultSlice) Less ¶ added in v0.0.4
func (r ReportResultSlice) Less(i, j int) bool
Less returns if i bigger than j
func (ReportResultSlice) Swap ¶ added in v0.0.4
func (r ReportResultSlice) Swap(i, j int)
Swap swaps the items
type ReportResultWithTotal ¶ added in v0.0.4
type ReportResultWithTotal struct {
ReportResult
Total time.Duration
First time.Time
Last time.Time
}
ReportResultWithTotal holds the total duration base on ReportResult
type ReportResultWriter ¶ added in v0.0.4
type ReportResultWriter interface {
Output([]ReportResult) error
}
ReportResultWriter is the interface of the report writer
func NewDiscardResultWriter ¶ added in v0.0.4
func NewDiscardResultWriter() ReportResultWriter
NewDiscardResultWriter creates a report result writer which discard everything
func NewMarkdownResultWriter ¶ added in v0.0.4
func NewMarkdownResultWriter(writer io.Writer) ReportResultWriter
NewMarkdownResultWriter creates the Markdown writer
func NewResultWriter ¶ added in v0.0.4
func NewResultWriter(writer io.Writer) ReportResultWriter
NewResultWriter creates a result writer with the specific io.Writer
type TestCaseRunner ¶ added in v0.0.4
type TestCaseRunner interface {
RunTestCase(testcase *testing.TestCase, dataContext interface{}, ctx context.Context) (output interface{}, err error)
WithOutputWriter(io.Writer) TestCaseRunner
WithWriteLevel(level string) TestCaseRunner
WithTestReporter(TestReporter) TestCaseRunner
}
TestCaseRunner represents a test case runner
func NewSimpleTestCaseRunner ¶ added in v0.0.4
func NewSimpleTestCaseRunner() TestCaseRunner
NewSimpleTestCaseRunner creates the instance of the simple test case runner
type TestReporter ¶ added in v0.0.4
type TestReporter interface {
PutRecord(*ReportRecord)
GetAllRecords() []*ReportRecord
ExportAllReportResults() (ReportResultSlice, error)
}
TestReporter is the interface of the report
func NewDiscardTestReporter ¶ added in v0.0.4
func NewDiscardTestReporter() TestReporter
NewDiscardTestReporter creates a test reporter which discard everything
func NewMemoryTestReporter ¶ added in v0.0.5
func NewMemoryTestReporter() TestReporter
NewMemoryTestReporter creates a memory based test reporter