We are using the boost statechart library and have troubles writing unit tests for the code.
In our normal execution the state machine starts in ClosedState
:
struct BoostStateMachine : sc::state_machine<BoostStateMachine, ClosedState >
We would like to test a specific state transition without having to traverse the state machine till that state, for example we would like to start the test in AnotherState
. The problem is that sc::state_machine
is templated on its initial state. Feeding the state machine with all the events that lead to the tested states, usually requires a lot of work and complicates the tests.
A primitive solution is to write special debug-only event and add it to ClosedState
. This event will trigger an immediate transition to AnotherState
.
Do you know any other way to accomplish the task?