Procedure for Converting State Graphs and State Tables into Test Cases
1 Answer

Identify states: The number of states in a state graph is the number of states we choose to recognize or model. In practice, the state is directly or indirectly recorded as a combination of values of variables that appear in the database. As an example, the state could be composed of the values of a counter whose possible values ranged from 0 to 9 , combined with the setting of two bit flags, leading to a total of $2 \times 2 \times 10=40$ states. When the state graph represents an explicit state table implementation, this value is encoded so that bugs in the number of states are less likely; but the encoding can be wrong. Failing to account for all the states is one of the most common bugs in the software that can be modelled by state graphs. As an explicit state table mechanization is not typical, the opportunities for missing states abound. Find the number of states as follows:

  • Identify all the component factors of the state.
  • Identify all the allowable values for each factor.
  • The number of states is the product of the number of allowable values of all the factors.

Prepare state transition diagram after understanding transitions between states: After having all the states, identify the inputs on each state and transitions between states and prepare the state graph. Every input state combination must have a specified transition. If the transition is impossible, then there must be a mechanism that prevents that input from occurring in that state.

A program cannot have contradictions or ambiguities. Ambiguities are impossible because the program will do something for every input. Even if the state does not change, by definition, this is a transition to the same state. A seeming contradiction could come about in a model if all the factors that constitute the state and all the inputs are not taken care of. If someone as a designer says while debugging, 'sometimes it works and sometimes it doesn't, it means there is a state factor about which he/she is not aware-a factor probably caused by a bug. Exploring the real state graph and recording. the transitions and outputs for each combination of input and state may lead to discovering the bug.

Convert state graph into state table

Analyse state table for its completeness

Create corresponding test cases from state table

Test cases are produced in a tabular form known as the test case table, which contains six columns as shown below:

Test case ID: A unique identifier for each test case

Test source: A trace back to the corresponding cell in the state table

Current state: The initial condition to run the test

Event: The input triggered by the user

Output The current value returned

Next state: The new state achieved

Please log in to add an answer.