What are some strategies for testing large state machines?

后端 未结 9 1835
刺人心
刺人心 2021-02-01 05:51

I inherited a large and fairly complex state machine. It has 31 possible states, all are really needed (big business process). It has the following inputs:

  • Enum: C
9条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-01 06:23

    All-Pair Testing

    To constraint the amount of combinations to test and to be reasonable assured you have most important combinations covered, you should take a look at all-pair testing.

    the reasoning behind all-pairs testing is this: the simplest bugs in a program are generally triggered by a single input parameter. The next simplest category of bugs consists of those dependent on interactions between pairs of parameters, which can be caught with all-pairs testing.1 Bugs involving interactions between three or more parameters are progressively less common2, whilst at the same time being progressively more expensive to find by exhaustive testing, which has as its limit the exhaustive testing of all possible inputs.

    Also take a look at a previous answer here (shameless plug) for additional information and links to both all-pair & pict as tool.

    Example Pict model file

    Given model generates 93 testcases, covering all pairs of input parameters.

    #
    # This is a PICT  model for testing a complex state machine at work 
    #
    
    CurrentState  :0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30
    Source        :1,2
    Request       :True, False
    Type          :True, False
    Status        :State1, State2, State3
    Handling      :State1, State2, State3
    Completed     :True,False
    
    #
    # One can add constraints to the model to exclude impossible 
    # combinations if needed.
    #
    # For example:
    # IF [Completed]="True" THEN CurrentState>15;
    #
    
    #
    # This is the PICT output of "pict ComplexStateMachine.pict /s /r1"
    #
    # Combinations:    515
    # Generated tests: 93
    

提交回复
热议问题