Documentation
¶
Index ¶
- type CapturedIOData
- type CapturedIOGivenData
- type GivenData
- type ParsedTestContent
- type Some
- func (some *Some) CapturedIO() map[interface{}]interface{}
- func (some *Some) InterestingGivens() map[interface{}]interface{}
- func (some *Some) ParsedTestContent() ParsedTestContent
- func (some *Some) SkippingThisOne(reason string, args ...interface{}) *Some
- func (some *Some) SkippingThisOneIf(why func(someData ...interface{}) bool, reason string, args ...interface{}) *Some
- func (some *Some) TestMetaData() *TestMetaData
- func (some *Some) TestTitle() string
- func (some *Some) Then(assertions TestingWithGiven) *Some
- func (some *Some) When(action ...CapturedIOGivenData) *Some
- type SomeMap
- type TestMetaData
- func (t *TestMetaData) Errorf(format string, args ...interface{})
- func (t *TestMetaData) FailNow()
- func (t *TestMetaData) Failed() bool
- func (t *TestMetaData) Helper()
- func (t *TestMetaData) Logf(format string, args ...interface{})
- func (t *TestMetaData) Name() string
- func (t *TestMetaData) Skipf(format string, args ...interface{})
- func (t *TestMetaData) Skipped() bool
- func (t *TestMetaData) TestOutput() string
- type TestingT
- type TestingWithGiven
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CapturedIOData ¶
type CapturedIOData func(capturedIO testdata.CapturedIO)
CapturedIOData is a func type that gets given a reference to Some CapturedIO data for the test
type CapturedIOGivenData ¶
type CapturedIOGivenData func(capturedIO testdata.CapturedIO, givens testdata.InterestingGivens)
CapturedIOGivenData is a combination of GivenData and CapturedIOData types
type GivenData ¶
type GivenData func(givens testdata.InterestingGivens)
GivenData is a func type that gets given Some interesting givens as a parameter
type ParsedTestContent ¶ added in v1.4.0
type ParsedTestContent struct { GivenWhenThen []string // Comment contains each comment line from the tests' comment block Comment []string }
ParsedTestContent parsed content from test
func ParseGivenWhenThen ¶ added in v1.4.0
func ParseGivenWhenThen(functionName string, testFileName string) ParsedTestContent
ParseGivenWhenThen parses a test file for the Given/When/Then content of the test in question identified by the parameter "testName". Returns the content of the function with all metacharacters removed, spaces added to CamelCase and snake case too.
type Some ¶
Some holds the test context and has a reference to the test's testing.T
func NewSome ¶
func NewSome( globalTestingT TestingT, testTitle string, testingT *TestMetaData, givenWhenThen ParsedTestContent, givenFunc ...GivenData) *Some
NewSome creates a new Some context. This is an internal function that was exported for testing.
func (*Some) CapturedIO ¶
func (some *Some) CapturedIO() map[interface{}]interface{}
CapturedIO is a convenience method for retrieving the CapturedIO map
func (*Some) InterestingGivens ¶
func (some *Some) InterestingGivens() map[interface{}]interface{}
InterestingGivens is a convenience method for retrieving the InterestingGivens map
func (*Some) ParsedTestContent ¶ added in v1.4.0
func (some *Some) ParsedTestContent() ParsedTestContent
ParsedTestContent holds a parsed test as an array string. All lines of the test func will be listed, from the first call to the first Given up to the end of the test func and converted to (as close as possible) natural language.
func (*Some) SkippingThisOne ¶ added in v1.0.1
SkippingThisOne still records we have a skipped tests in our test output generator
func (*Some) SkippingThisOneIf ¶ added in v1.1.0
func (some *Some) SkippingThisOneIf(why func(someData ...interface{}) bool, reason string, args ...interface{}) *Some
SkippingThisOneIf skips if the condition is true, and still records we have a skipped tests in our test output generator. This will be best used in a table test (range) when running sub-tests, since in a main test the entire test will be skipped and the condition pointless.
func (*Some) TestMetaData ¶ added in v1.2.0
func (some *Some) TestMetaData() *TestMetaData
TestMetaData is an interface that mimics testingT but stores the test state rather than act on it. Gogivens will act on the meta data's behalf via globalTestingT (the "real" testing.T for the test).
func (*Some) Then ¶
func (some *Some) Then(assertions TestingWithGiven) *Some
Then is a function that executes the given function and asserts whether the test has failed. It can be called in a table test (for loop). Provide a function in which assertions will be made. Use the testMetaData typed var in place of testing.T. The test state is recorded in testMetaData type and goGiven fails the test if the error methods (ErrorF etc) were called after the function exits.
func (*Some) When ¶
func (some *Some) When(action ...CapturedIOGivenData) *Some
When - call When when you want to perform Some action, call a function, or perform a test operation.
type TestMetaData ¶
TestMetaData holds Some information about the test, it's id, whether it failed or not and the output it sent to t.Errorf or t.Error etc.
func NewTestMetaData ¶
func NewTestMetaData(testName string) *TestMetaData
NewTestMetaData creates a new TestMetaData object. Used internally.
func (*TestMetaData) Errorf ¶
func (t *TestMetaData) Errorf(format string, args ...interface{})
Errorf marks this test as failed and sets the test output to the formatted string.
func (*TestMetaData) Failed ¶
func (t *TestMetaData) Failed() bool
Failed reports the test has failed to the meta data.
func (*TestMetaData) Helper ¶
func (t *TestMetaData) Helper()
Helper does nothing. It's just in case Some package that consumes t calls it.
func (*TestMetaData) Logf ¶
func (t *TestMetaData) Logf(format string, args ...interface{})
Logf marks this test as failed and sets the test output to the formatted string.
func (*TestMetaData) Name ¶
func (t *TestMetaData) Name() string
Name returns the id (the test name, possibly with Some uniqueid appended)
func (*TestMetaData) Skipf ¶ added in v1.0.1
func (t *TestMetaData) Skipf(format string, args ...interface{})
Skipf reports the test as skipped with a formatted message to the test meta data
func (*TestMetaData) Skipped ¶ added in v1.0.1
func (t *TestMetaData) Skipped() bool
Skipped returns the state of the test meta data, if skipped then it's true
func (*TestMetaData) TestOutput ¶
func (t *TestMetaData) TestOutput() string
TestOutput returns the recorded test output
type TestingT ¶
type TestingT interface { Failed() bool Logf(format string, args ...interface{}) Errorf(format string, args ...interface{}) FailNow() Helper() Name() string Skipf(format string, args ...interface{}) }
TestingT is a convenience interface that matches Some methods of `testing.T`
type TestingWithGiven ¶
type TestingWithGiven func(testingT TestingT, actual testdata.CapturedIO, givens testdata.InterestingGivens)
TestingWithGiven gives a func declaration including testingT, CapturedIO and InterestingGivens parameters.