Documentation
¶
Overview ¶
Package testkit contains blackbox testing utilities for testing Dogma applications.
Index ¶
- type Runner
- type RunnerOption
- type Test
- func (t *Test) AdvanceTime(ta TimeAdvancer, a assert.Assertion, options ...engine.OperationOption) *Test
- func (t *Test) Call(fn func() error, a assert.Assertion, options ...engine.OperationOption) *Test
- func (t *Test) CommandExecutor() dogma.CommandExecutor
- func (t *Test) EventRecorder() dogma.EventRecorder
- func (t *Test) ExecuteCommand(m dogma.Message, a assert.Assertion, options ...engine.OperationOption) *Test
- func (t *Test) Prepare(messages ...dogma.Message) *Test
- func (t *Test) RecordEvent(m dogma.Message, a assert.Assertion, options ...engine.OperationOption) *Test
- type TestOption
- type TestingT
- type TimeAdvancer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
A Runner executes tests.
func New ¶
func New( app dogma.Application, options ...RunnerOption, ) *Runner
New returns a test runner.
func (*Runner) Begin ¶
func (r *Runner) Begin(t TestingT, options ...TestOption) *Test
Begin starts a new test.
func (*Runner) BeginContext ¶
BeginContext starts a new test within a context.
type RunnerOption ¶
type RunnerOption func(*runnerOptions)
RunnerOption applies optional settings to a test runner.
func WithEngineOptions ¶
func WithEngineOptions(options ...engine.Option) RunnerOption
WithEngineOptions returns a RunnerOption that applies optional settings to the engine used by the test-runner.
type Test ¶
type Test struct {
// contains filtered or unexported fields
}
Test contains the state of a single test.
func (*Test) AdvanceTime ¶ added in v0.7.0
func (t *Test) AdvanceTime( ta TimeAdvancer, a assert.Assertion, options ...engine.OperationOption, ) *Test
AdvanceTime artificially advances the engine's notion of the current time according to the given "advancer".
It panics if the advancer returns a time that is before the current engine time.
func (*Test) Call ¶ added in v0.7.0
func (t *Test) Call( fn func() error, a assert.Assertion, options ...engine.OperationOption, ) *Test
Call makes an assertion about the application's behavior within a user-defined function.
Code executed within fn() can make use of the command executor and event recorder returned by t.CommandExecutor() and t.EventRecorder(), respectively.
func (*Test) CommandExecutor ¶ added in v0.7.0
func (t *Test) CommandExecutor() dogma.CommandExecutor
CommandExecutor returns a dogma.CommandExecutor which can be used to execute commands within the context of this test.
func (*Test) EventRecorder ¶ added in v0.7.0
func (t *Test) EventRecorder() dogma.EventRecorder
EventRecorder returns a dogma.EventRecorder which can be used to record events within the context of this test.
func (*Test) ExecuteCommand ¶
func (t *Test) ExecuteCommand( m dogma.Message, a assert.Assertion, options ...engine.OperationOption, ) *Test
ExecuteCommand makes an assertion about the application's behavior when a specific command is executed.
func (*Test) Prepare ¶
Prepare prepares the application for the test by executing the given set of messages without any assertions.
func (*Test) RecordEvent ¶
func (t *Test) RecordEvent( m dogma.Message, a assert.Assertion, options ...engine.OperationOption, ) *Test
RecordEvent makes an assertion about the application's behavior when a specific event is recorded.
type TestOption ¶
type TestOption func(*testOptions)
TestOption applies optional settings to a test.
func WithOperationOptions ¶
func WithOperationOptions(options ...engine.OperationOption) TestOption
WithOperationOptions returns a TestOption that applies optional per-operation settings when performing assertions.
func WithStartTime ¶ added in v0.2.0
func WithStartTime(t time.Time) TestOption
WithStartTime returns a test option that sets the time of the test runner's clock at the start of the test.
By default, the current system time is used.
type TestingT ¶ added in v0.6.0
type TestingT interface {
Log(args ...interface{})
Logf(f string, args ...interface{})
FailNow()
}
TestingT is the interface via which the test framework consumes Go's *testing.T value.
It allows use of stand-ins, such as Ginkgo's GinkgoT() value.
type TimeAdvancer ¶ added in v0.7.0
TimeAdvancer is a function that determines the new time that the engine is advanced to during a call to Test.AdvanceTime().
func ByDuration ¶ added in v0.7.0
func ByDuration(d time.Duration) TimeAdvancer
ByDuration returns a TimeAdvancer that advances the engine time by a fixed duration.
func ToTime ¶ added in v0.7.0
func ToTime(t time.Time) TimeAdvancer
ToTime returns a TimeAdvancer that advances the engine time to a specific time.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package assert contains the assertions used by the test runner.
|
Package assert contains the assertions used by the test runner. |
|
Package compare contains utilities for comparing Dogma entities.
|
Package compare contains utilities for comparing Dogma entities. |
|
Package engine contains an in-memory Dogma engine.
|
Package engine contains an in-memory Dogma engine. |
|
controller
Package controller contains interfaces that the engine uses to consume controllers for each of the message handler types.
|
Package controller contains interfaces that the engine uses to consume controllers for each of the message handler types. |
|
controller/aggregate
Package aggregate provides engine components that handle messages that are routed to aggregate message handlers.
|
Package aggregate provides engine components that handle messages that are routed to aggregate message handlers. |
|
controller/integration
Package integration provides engine components that handle messages that are routed to integration message handlers.
|
Package integration provides engine components that handle messages that are routed to integration message handlers. |
|
controller/process
Package process provides engine components that handle messages that are routed to process message handlers.
|
Package process provides engine components that handle messages that are routed to process message handlers. |
|
controller/projection
Package projection provides engine components that handle messages that are routed to projection message handlers.
|
Package projection provides engine components that handle messages that are routed to projection message handlers. |
|
envelope
Package envelope provides a container for passing Dogma messages and their meta-data between components.
|
Package envelope provides a container for passing Dogma messages and their meta-data between components. |
|
fact
Package fact contains structures that represents internal engine events.
|
Package fact contains structures that represents internal engine events. |
|
internal
|
|
|
Package render contains utilities for rendering various values in a human-readable manner.
|
Package render contains utilities for rendering various values in a human-readable manner. |