Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AfterFuncs ¶
type AfterFuncs struct {
Funcs []func()
}
AfterFuncs is like BeforeFuncs but executed after the test has run.
func (*AfterFuncs) Exec ¶
func (b *AfterFuncs) Exec()
Exec like BeforeFuncs.Exec but executed after the test run.
type BeforeFuncs ¶
type BeforeFuncs struct {
Funcs []func()
}
BeforeFuncs contains functions that are supposed to be executed before a test.
func (*BeforeFuncs) Exec ¶
func (b *BeforeFuncs) Exec()
Exec implements Test interface. When called this will iterate and call every function that is stored in the Funcs field. Iteration is done by the order in which the functions are added.
TODO: Have timeout to allow handling of long running functions. One option is to pass context.Context as the first argument of the functions.
type Error ¶
Error implements error interface. This is useful for taking care of interupts via panics.
type ExpectResult ¶
type ExpectResult struct { Desc string `json:"description"` Duration time.Duration `json:"duration"` Messages []string `json:"error_messages"` StackTrace string `json:"stack_trace"` }
ExpectResult contains reults of executing expectation.
type Expectation ¶
type Expectation struct { Parent *Suite Desc string Func func(T) Passed bool FailMessages []string StackTrace string Duration time.Duration }
Expectation contains the main test function that checks expectations. If the main function after execution happens not to call any method of the passed T object then the test has passed.
func (*Expectation) Exec ¶
func (e *Expectation) Exec()
Exec runs the test function and records the result.
TODO: add timeout.
func (*Expectation) Result ¶
func (e *Expectation) Result() *ExpectResult
Result returns *ExpectResult from executing the expectation.
type Integration ¶
type Integration interface {
// contains filtered or unexported methods
}
Integration is an interface for integration tests.
func Render ¶
func Render(desc string, c func() interface{}, cases ...Test) Integration
Render returns an integration test for non body Components. Use this to test Components that renders spans,div etc.
NOTE: func()interface{} was supposed to be func()vecty.ComponentOrHTML this is a workaround, because importing vecty in this package will make it impossible to run the commandline tools since vecty only works with the browser.
func RenderBody ¶
func RenderBody(desc string, c func() interface{}, cases ...Test) Integration
RenderBody is like Render but the Component is expected to be elem.Body
func SetupIntegration ¶
func SetupIntegration(name string, i Integration) Integration
SetupIntegration returns an Integration test ready for execution. name is the name of the test function.
type SpecResult ¶
type SpecResult struct { ID string `json:"id"` Package string `json:"package"` Desc string `json:"description"` FullName string `json:"fullname"` Duration time.Duration `json:"duration"` FailedExpectations []*ExpectResult `json:"failed_expectations,omitempty"` PassedExpectations []*ExpectResult `json:"passed_expectations,omitempty"` Children []*SpecResult `json:"children,omitempty"` }
SpecResult contains result information after executing a test suite.
type Suite ¶
type Suite struct { Parent *Suite Package string ID string Desc string BeforeFuncs *BeforeFuncs AfterFuncs *AfterFuncs MarkedSKip bool MarkedSkipMessage string Duration time.Duration Expectations []*Expectation FailedExpectations []*Expectation PassedExpectations []*Expectation Children []*Suite }
func (*Suite) Fullname ¶
Fullname returns a string depicting full tree descriptions from the parent root Suite to the current one.
func (*Suite) Result ¶
func (s *Suite) Result() *SpecResult
Result returns results of executing the suite.
type T ¶
type T interface { Error(...interface{}) Errorf(string, ...interface{}) Fatal(...interface{}) Fatalf(string, ...interface{}) Errors() []string }
T is an interface for failing expectations.
type Test ¶
type Test interface { Exec() // contains filtered or unexported methods }
Test is an interface for a testable object. Note that this is supposed to be used internally so user's can't implement this interface.
func After ¶
func After(fn ...func()) Test
After is a list of functions that will be executed after the actual test suite is run. You can use this to release resources/cleanup after the tests are done.
func Before ¶
func Before(fn ...func()) Test
Before is a list of functions that will be executed before the actual test suite is run.
func Describe ¶
Describe describe what you want to test. The first argument desc, can be a simple string for identifier you want to test, that can be a function, as struct method or anything.
You can use this to organise your test into a nested tree like structure.