dart_fsm_test_tools library

Classes

ActionCase<STATE extends Object, ACTION extends Object, MOCKS extends Object>
Opaque transition expectation for one dispatched action.
MockStateMachine<STATE extends Object, ACTION extends Object>
This is a mock implementation of StateMachine that can be used for testing
SMAssertObject<S extends Object, A extends Object>
This class is used to store the test case information.
StateCase<STATE extends Object, ACTION extends Object, MOCKS extends Object>
Opaque transition specifications for one source state.
StateMachineTester<STATE extends Object, ACTION extends Object>
This class is used to test the state machine.
TesterStateMachine<STATE extends Object, ACTION extends Object>
A state machine for testing.
TransitionExpectation<STATE extends Object>
Opaque expected transition result for a dispatched action.

Functions

expectInvalidTransition<STATE extends Object>() TransitionExpectation<STATE>
Expects the dispatched action to be invalid for the source state.
ifDispatched<STATE extends Object, ACTION extends Object, MOCKS extends Object>(ACTION action, {required TransitionExpectation<STATE> then, MockArrange<MOCKS>? arrange, MockVerify<MOCKS>? verify}) ActionCase<STATE, ACTION, MOCKS>
Describes the expectation for dispatching one action.
runStateMachineTestCases<STATE extends Object, ACTION extends Object, MOCKS extends Object>({required String name, required MOCKS createMocks(), required StateMachineFactory<STATE, ACTION, MOCKS> createStateMachine, required List<STATE> states, required List<ACTION> actions, required StateMachineTestCases<STATE, ACTION, MOCKS> cases, StateMachineTestHook? beforeEach, StateMachineTestHook? afterEach}) → void
Registers exhaustive Given-When-Then transition tests for a StateMachine.
transitionExpectationIs<STATE extends Object>({required STATE after, STATE? eventually}) TransitionExpectation<STATE>
Expects a valid transition to after, and optionally to eventually.
whenInitialStateIs<STATE extends Object, ACTION extends Object, MOCKS extends Object>(STATE initial, {required List<ActionCase<STATE, ACTION, MOCKS>> actions}) StateCase<STATE, ACTION, MOCKS>
Starts a transition specification from the given source state.

Typedefs

MockArrange<MOCKS extends Object> = FutureOr<void> Function(MOCKS mocks)
Arranges external dependencies before an action is dispatched.
MockVerify<MOCKS extends Object> = FutureOr<void> Function(MOCKS mocks)
Verifies external dependency interactions after a transition settles.
StateMachineFactory<STATE extends Object, ACTION extends Object, MOCKS extends Object> = StateMachine<STATE, ACTION> Function(MOCKS mocks, STATE initialState)
Creates a real StateMachine for one transition test case.
StateMachineTestCases<STATE extends Object, ACTION extends Object, MOCKS extends Object> = List<StateCase<STATE, ACTION, MOCKS>>
A list of transition specifications for a StateMachine.
StateMachineTestHook = FutureOr<void> Function()
Runs custom setup or teardown around each generated test case.