Documentation
¶
Index ¶
- Variables
- func CaseMatchesFilters(testCase *Case) bool
- func Init()
- func ListenForInterrupt(shutdown context.CancelFunc)
- func RegisterFilter(filter Filter)
- func TraverseReport(report Report, enter func(report Report) TraverseOption, ...)
- func TraverseSuite(test SuiteOrCase, enter func(test SuiteOrCase) TraverseOption, ...)
- type Case
- type CaseReport
- func (c *CaseReport) Duration() time.Duration
- func (c *CaseReport) Err() []Err
- func (c *CaseReport) FullNameWithSeparator() string
- func (c *CaseReport) RegisterErr(err Err)
- func (c *CaseReport) Status() TestStatus
- func (c *CaseReport) Stderr() *bytes.Buffer
- func (c *CaseReport) Stdout() *bytes.Buffer
- func (c *CaseReport) UpdateStatus(newStatus TestStatus)
- type Err
- type ErrTyp
- type Filter
- type PathFilter
- type PlainReporter
- type RegexFilter
- type Report
- type ReportEvent
- type ReportEventType
- type Reporter
- type RichReporter
- func (r *RichReporter) Duration() time.Duration
- func (r *RichReporter) ETA() time.Duration
- func (r *RichReporter) Init() tea.Cmd
- func (r *RichReporter) Percent() float64
- func (r *RichReporter) Report(events chan *ReportEvent, shutdown context.CancelFunc)
- func (r *RichReporter) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (r *RichReporter) View() string
- type Suite
- func (s *Suite) CaseCount() int
- func (s *Suite) FullName() string
- func (s *Suite) FullNameWithSeparator() string
- func (s *Suite) NewCase(name string, fn *vm.Closure) *Case
- func (s *Suite) NewSubSuite(name string, loc *position.Location) *Suite
- func (s *Suite) RegisterAfterAll(fn *vm.Closure)
- func (s *Suite) RegisterAfterEach(fn *vm.Closure)
- func (s *Suite) RegisterBeforeAll(fn *vm.Closure)
- func (s *Suite) RegisterBeforeEach(fn *vm.Closure)
- func (s *Suite) RegisterCase(testCase *Case)
- func (s *Suite) RegisterSubSuite(subSuite *Suite)
- func (s *Suite) Run(v *vm.Thread, events chan<- *ReportEvent, rng *rand.Rand, ctx context.Context) *SuiteReport
- type SuiteMatch
- type SuiteOrCase
- type SuiteReport
- func (s *SuiteReport) Duration() time.Duration
- func (s *SuiteReport) Err() []Err
- func (s *SuiteReport) FullNameWithSeparator() string
- func (s *SuiteReport) RegisterCaseReport(caseReport *CaseReport)
- func (s *SuiteReport) RegisterErr(err Err)
- func (s *SuiteReport) RegisterSubSuiteReport(subSuiteReport *SuiteReport)
- func (s *SuiteReport) Status() TestStatus
- func (s *SuiteReport) Stderr() *bytes.Buffer
- func (s *SuiteReport) Stdout() *bytes.Buffer
- func (s *SuiteReport) UpdateStatus(newStatus TestStatus)
- type TestStatus
- type TraverseOption
Constants ¶
This section is empty.
Variables ¶
View Source
var AssertionErrorClass *value.Class // Std::Test::AssertionError
View Source
var CurrentSuite = RootSuite
View Source
var Filters []Filter
View Source
var RootSuite = NewSuite("", nil, nil)
Functions ¶
func CaseMatchesFilters ¶
func ListenForInterrupt ¶
func ListenForInterrupt( shutdown context.CancelFunc, )
func RegisterFilter ¶
func RegisterFilter(filter Filter)
func TraverseReport ¶
func TraverseReport(report Report, enter func(report Report) TraverseOption, leave func(report Report) TraverseOption)
func TraverseSuite ¶
func TraverseSuite(test SuiteOrCase, enter func(test SuiteOrCase) TraverseOption, leave func(test SuiteOrCase) TraverseOption)
Types ¶
type Case ¶
Represents a single test case
func (*Case) FullNameWithSeparator ¶
func (*Case) Run ¶
func (c *Case) Run(v *vm.Thread, events chan<- *ReportEvent, ctx context.Context) *CaseReport
type CaseReport ¶
type CaseReport struct {
Case *Case
// contains filtered or unexported fields
}
Contains the result of running a test case
func NewCaseReport ¶
func NewCaseReport(cas *Case) *CaseReport
func (*CaseReport) Duration ¶
func (c *CaseReport) Duration() time.Duration
func (*CaseReport) Err ¶
func (c *CaseReport) Err() []Err
func (*CaseReport) FullNameWithSeparator ¶
func (c *CaseReport) FullNameWithSeparator() string
func (*CaseReport) RegisterErr ¶
func (c *CaseReport) RegisterErr(err Err)
func (*CaseReport) Status ¶
func (c *CaseReport) Status() TestStatus
func (*CaseReport) Stderr ¶
func (c *CaseReport) Stderr() *bytes.Buffer
func (*CaseReport) Stdout ¶
func (c *CaseReport) Stdout() *bytes.Buffer
func (*CaseReport) UpdateStatus ¶
func (c *CaseReport) UpdateStatus(newStatus TestStatus)
type Filter ¶
type Filter interface {
CaseMatches(test *Case) bool
SuiteMatches(suite *Suite) SuiteMatch
}
Filter checks if a test case/suite matches and discards the test if it does not match
type PathFilter ¶
type PathFilter struct {
// contains filtered or unexported fields
}
PathFilter matches tests on filepaths and lines
func NewPathFilter ¶
func NewPathFilter(path string) (*PathFilter, error)
func (*PathFilter) CaseMatches ¶
func (p *PathFilter) CaseMatches(test *Case) bool
func (*PathFilter) LocationMatches ¶
func (p *PathFilter) LocationMatches(loc *position.Location) bool
func (*PathFilter) SuiteMatches ¶
func (p *PathFilter) SuiteMatches(suite *Suite) SuiteMatch
type PlainReporter ¶
type PlainReporter struct {
// contains filtered or unexported fields
}
func NewPlainReporter ¶
func NewPlainReporter() *PlainReporter
func (*PlainReporter) Report ¶
func (s *PlainReporter) Report(events chan *ReportEvent, shutdown context.CancelFunc)
type RegexFilter ¶
RegexFilter matches tests based on a regular expression
func NewRegexFilter ¶
func NewRegexFilter(pattern string) (*RegexFilter, error)
func (*RegexFilter) CaseMatches ¶
func (r *RegexFilter) CaseMatches(test *Case) bool
func (*RegexFilter) SuiteMatches ¶
func (r *RegexFilter) SuiteMatches(suite *Suite) SuiteMatch
type ReportEvent ¶
type ReportEvent struct {
SuiteReport *SuiteReport
CaseReport *CaseReport
Type ReportEventType
}
func NewCaseReportEvent ¶
func NewCaseReportEvent(caseReport *CaseReport, typ ReportEventType) *ReportEvent
func NewSuiteReportEvent ¶
func NewSuiteReportEvent(suiteReport *SuiteReport, typ ReportEventType) *ReportEvent
type ReportEventType ¶
type ReportEventType uint8
const ( REPORT_START_SUITE ReportEventType = iota REPORT_FINISH_SUITE REPORT_START_CASE REPORT_FINISH_CASE )
type Reporter ¶
type Reporter interface {
Report(events chan *ReportEvent, shutdown context.CancelFunc)
}
Contains the result of running a test suite
type RichReporter ¶
type RichReporter struct {
// contains filtered or unexported fields
}
func NewRichReporter ¶
func NewRichReporter() *RichReporter
func (*RichReporter) Duration ¶
func (r *RichReporter) Duration() time.Duration
func (*RichReporter) ETA ¶
func (r *RichReporter) ETA() time.Duration
func (*RichReporter) Init ¶
func (r *RichReporter) Init() tea.Cmd
func (*RichReporter) Percent ¶
func (r *RichReporter) Percent() float64
func (*RichReporter) Report ¶
func (r *RichReporter) Report(events chan *ReportEvent, shutdown context.CancelFunc)
func (*RichReporter) View ¶
func (r *RichReporter) View() string
type Suite ¶
type Suite struct {
Name string
Location *position.Location
Parent *Suite
SubSuites []*Suite
Cases []*Case
BeforeEach []*vm.Closure
AfterEach []*vm.Closure
BeforeAll []*vm.Closure
AfterAll []*vm.Closure
FullMatch bool
// contains filtered or unexported fields
}
Represents a test suite, a group of tests like `describe` or `context`
func (*Suite) FullNameWithSeparator ¶
func (*Suite) RegisterAfterAll ¶
func (*Suite) RegisterAfterEach ¶
func (*Suite) RegisterBeforeAll ¶
func (*Suite) RegisterBeforeEach ¶
func (*Suite) RegisterCase ¶
func (*Suite) RegisterSubSuite ¶
type SuiteMatch ¶
type SuiteMatch uint8
const ( SUITE_MATCH_FALSE SuiteMatch = iota SUITE_MATCH_TRUE SUITE_MATCH_FULL )
func SuiteMatchesFilters ¶
func SuiteMatchesFilters(suite *Suite) SuiteMatch
type SuiteOrCase ¶
type SuiteOrCase interface {
// contains filtered or unexported methods
}
type SuiteReport ¶
type SuiteReport struct {
Suite *Suite
CaseReports []*CaseReport
SubSuiteReports []*SuiteReport
// contains filtered or unexported fields
}
Contains the result of running a test suite
func NewSuiteReport ¶
func NewSuiteReport(suite *Suite) *SuiteReport
func Run ¶
func Run() *SuiteReport
func RunWith ¶
func RunWith(v *vm.Thread, reporter Reporter, events chan *ReportEvent, seed uint64) *SuiteReport
Run the all tests under the root suite
func (*SuiteReport) Duration ¶
func (s *SuiteReport) Duration() time.Duration
func (*SuiteReport) Err ¶
func (s *SuiteReport) Err() []Err
func (*SuiteReport) FullNameWithSeparator ¶
func (s *SuiteReport) FullNameWithSeparator() string
func (*SuiteReport) RegisterCaseReport ¶
func (s *SuiteReport) RegisterCaseReport(caseReport *CaseReport)
func (*SuiteReport) RegisterErr ¶
func (s *SuiteReport) RegisterErr(err Err)
func (*SuiteReport) RegisterSubSuiteReport ¶
func (s *SuiteReport) RegisterSubSuiteReport(subSuiteReport *SuiteReport)
func (*SuiteReport) Status ¶
func (s *SuiteReport) Status() TestStatus
func (*SuiteReport) Stderr ¶
func (s *SuiteReport) Stderr() *bytes.Buffer
func (*SuiteReport) Stdout ¶
func (s *SuiteReport) Stdout() *bytes.Buffer
func (*SuiteReport) UpdateStatus ¶
func (s *SuiteReport) UpdateStatus(newStatus TestStatus)
type TestStatus ¶
type TestStatus uint8
const ( TEST_PENDING TestStatus = iota TEST_FAILED TEST_ERROR TEST_SKIPPED TEST_RUNNING TEST_SUCCESS )
type TraverseOption ¶
type TraverseOption uint8
Value used to decide what whether to skip the children of the report, break the traversal or continue in the Report Traverse method. The zero value continues the traversal.
const ( TraverseContinue TraverseOption = iota TraverseSkip TraverseBreak )
Click to show internal directories.
Click to hide internal directories.