Optional extension: Test an algorithm from a decision table

Chapter 1.2 gives a complete umbrella table in ?@tbl-decision-umbrella-full and an equivalent minimized table in ?@tbl-decision-umbrella-minimized. Use both tables as the specification for testing a proposed algorithm.

Scenario. Take an umbrella only when rain is forecast and the journey includes time outdoors. Leave the umbrella behind in every other case.

Inputs. Rain Forecast and Journey Includes Time Outdoors. Each input is Yes or No.

Rules and notation. The required result is Take an umbrella only for (Yes, Yes). The result is Leave the umbrella behind for the other three input pairs. Any in minimized Rule 3 means that either permitted outdoor value matches.

Assumptions. Both inputs contain a permitted value. Each input pair must produce exactly one result.

Deliverable. Complete the following checking sequence:

  1. Construct test cases U1 to U4 from the four possible input pairs. Record each case’s purpose, expected result, and matching rule in the minimized table before inspecting the proposed algorithm.
  2. Trace Listing 1 for every case. Record the observed result and verdict.
  3. Identify the first mismatch and the condition that causes it. Repair only that condition.
  4. Retest all four cases. Explain why minimized Rule 3 requires two concrete test cases.

Success criteria. The plan covers all four input pairs. Every input matches one rule in each decision table. The initial tests expose the missing outdoor condition, and all four retests pass after the repair.

Use the proposed algorithm only after recording the expected results.

Listing 1: Proposed umbrella algorithm to test.
Input: Rain Forecast, Journey Includes Time Outdoors
Output: Umbrella Decision
Start
   If Rain Forecast is Yes
      Set Umbrella Decision to "Take an umbrella"
   Else
      Set Umbrella Decision to "Leave the umbrella behind"
   End If

   Output Umbrella Decision
End

Use (Yes, Yes), (Yes, No), (No, Yes), and (No, No). Compare the proposed algorithm with the required result for (Yes, No).