Testing Finite State Machines
Posted
by Pondidum
on Stack Overflow
See other posts from Stack Overflow
or by Pondidum
Published on 2010-04-22T13:15:44Z
Indexed on
2010/04/22
14:03 UTC
Read the original article
Hit count: 324
I have inherited a large and firaly complex state machine at work.
- It has 31 possbile states to be in.
- It has the following inputs:
- Enum: Current State (so 0 -> 30)
- Enum: source (currently only 2 entries)
- Boolean: Request
- Boolean: type
- Enum: Status (3 states)
- Enum: Handling (3 states)
- Boolean: Completed
The 31 States are really needed (big business process).
Breaking into seperate state machines doesnt seem feasable - each state is distinct.
I have written tests for one set of inputs (the most common set), with one test per input (all inputs constant, except for the State input):
[Subject("Application Process States")]
public class When_state_is_meeting2Requested : AppProcessBase
{
Establish context = () =>
{
//Setup....
};
Because of = () =>
process.Load(jas, vac);
It Current_node_should_be_meeting2Requested = () => process.CurrentNode.ShouldBeOfType<meetingRequestedNode>();
It Can_move_to_clientDeclined = () => Check(process, process.clientDeclined);
It Can_move_to_meeting1Arranged = () => Check(process, process.meeting1Arranged);
It Can_move_to_meeting2Arranged = () => Check(process, process.meeting2Arranged);
It Can_move_to_Reject = () => Check(process, process.Reject);
It Cannot_move_to_any_other_state = () => AllOthersFalse(process);
}
As no one is entirely sure on what the output should be for each state and set of inputs i have been starting to write tests for it, however on calculation i will need to write 4320 ( 30*2*2*2*3*3*2 ) tests for it.
Does anyone have any suggestions on how i should go about testing this?
© Stack Overflow or respective owner