A decision table is a structured way to represent combinations of input conditions and expected outputs in a tabular format. It helps:
- Identify all relevant test scenarios
- Ensure full logical coverage
- Clarify the behaviour of the function based on multiple interacting inputs
Each column in the table (R1, R2, R3, etc.) represents a rule, i.e., a test case defined by a combination of input conditions and the resulting output.
Structure a decision table (Example)
The below function rejects non-positive side lengths (not a triangle) and classifies triangles as Equilateral, Isosceles, or Scalene.
def triangle(a: int, b: int, c: int) -> str:
if a <= 0 or b <= 0 or c <= 0:
return "Not Triangle"
if a == b:
if b == c:
return "Equilateral"
else:
return "Isosceles"
else:
if b == c:
return "Isosceles"
else:
return "Scalene"
Decision table
Conditions | R1 | R2 | R3* | R4* | R5 | R6* | R7 | R8 | R9 |
---|---|---|---|---|---|---|---|---|---|
i1: a,b,c form triangle? | F | T | T | T | T | T | T | T | T |
i2: a = b ? | - | T | T | T | T | F | F | F | F |
i3: a = c ? | - | T | T | F | F | T | T | F | F |
i4: b = c ? | - | T | F | T | F | T | F | T | F |
Outputs | |||||||||
O1: Not Triangle | T | ||||||||
O2: Scalene | T | ||||||||
O3: Isosceles | T | T | T | ||||||
O4: Equilateral | T | ||||||||
O5: Impossible combo | T | T | T |
Test derivation
Each unique column (i.e a rule) becomes a test case. You can ignore any duplicate rules when producing test cases. The asterisks on R3*, R4*, R6* indicate they are the “Impossible” cases. When you design the test suite based on the decision table, these cases do not make it into the test suite.
triangle(-1,0,1) #R1
triangle(1,1,1) #R2
triangle(1,1,2) #R5
triangle(1,2,1) #R7
triangle(2,1,1) #R8
triangle(4,2,3) #R9
Back to parent page: Software Testing
Web_and_App_Development Software_Testing Blackbox_Testing SOFT3202 Decision_Table