Judgment table
The cause-and-effect diagram is just an auxiliary tool. The decision table is finally obtained through analysis, and then the test cases are written through the decision table.
Drawing a cause-and-effect diagram is very troublesome and affects test efficiency. You can directly write a judgment table and then write a test case.
Judgment table composition
condition pile - all conditions of the problem
Action stub - all outputs from the question
Condition item - the value for the condition pile
The output results of the various values of the action item-condition item
Decision Table Design Steps
List all condition stubs and action stubs
Determine the number of rules: the number of values for each conditional stake ^ the number of conditional stakes
Fill in the conditions
Fill in the action items to get the initial decision table
Simplified Decision Table
Design test cases based on decision tables
the case
judgment triangle
Requirements analysis
Input three positive integers a, b, c, respectively, as the three sides of the triangle, and judge whether it constitutes a triangle and the type of the triangle
1. List all conditional stubs and action stubs
conditional pile |
condition item |
C1: Whether a, b, c form a triangle |
1: The sum of two sides is greater than the third side, 0: Not satisfied |
C2:a=b? |
1:a=b、0:a!=b |
C3:a=c? |
1:a=c、0:a!=c |
C4:b=c? |
1:b=c、0:b!=c |
action pile |
action item |
A1: not a triangle |
1: not a triangle |
A2: general triangle |
1: is a general triangle |
A3: Isosceles triangle |
1: is an isosceles triangle |
A4: Isosceles triangle |
1: is an isosceles triangle |
A5: Impossible to appear |
1: Combination conditions are impossible |
2. Determine the number of rules: the number of values for each conditional stake ^ the number of conditional stakes
2^4 = 16
3. Fill in the condition item, fill in the action item, and get the initial judgment table
conditional pile |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
C1: Whether a, b, c form a triangle |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
C2:a=b? |
0 |
0 |
0 |
0 |
1 |
1 |
1 |
1 |
0 |
0 |
0 |
0 |
1 |
1 |
1 |
1 |
C3:a=c? |
0 |
0 |
1 |
1 |
0 |
0 |
1 |
1 |
0 |
0 |
1 |
1 |
0 |
0 |
1 |
1 |
C4:b=c? |
0 |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
action pile |
||||||||||||||||
A1: not a triangle |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
||||||||
A2: Normal Triangle |
1 |
|||||||||||||||
A3: Isosceles triangle |
1 |
1 |
1 |
|||||||||||||
A4: equilateral triangle |
1 |
|||||||||||||||
A5: Impossible to appear |
1 |
1 |
1 |
4. Simplify the decision table
conditional pile |
1 |
2 |
3 |
4 |
5 |
6 |
C1: Whether a, b, c form a triangle |
0 |
1 |
1 |
1 |
1 |
1 |
C2:a=b? |
- |
0 |
0 |
1 |
1 |
1 |
C3:a=c? |
- |
0 |
1 |
0 |
1 |
1 |
C4:b=c? |
- |
0 |
1 |
1 |
0 |
1 |
action pile |
||||||
A1: not a triangle |
1 |
|||||
A2: Normal Triangle |
1 |
|||||
A3: Isosceles triangle |
||||||
A4: equilateral triangle |
1 |
|||||
A5: Impossible to appear |
1 |
1 |
1 |
5. Design test cases according to the decision table
use case number |
a |
b |
c |
expected outcome |
1 |
4 |
1 |
2 |
non-triangular |
2 |
3 |
4 |
5 |
general triangle |
3 |
2 |
2 |
3 |
isosceles triangle |
4 |
2 |
3 |
2 |
isosceles triangle |
5 |
3 |
2 |
2 |
isosceles triangle |
6 |
5 |
5 |
5 |
Equilateral triangle |