Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Decision tables, state transitions and cause–effect graphs

Decision tables, state-transition testing and cause–effect graphs are structured black-box techniques that convert requirements into compact rules, state diagrams and logical graphs to design test cases that ensure coverage and detect requirement defects.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Software engineers use decision tables, state-transition testing and cause–effect graphs to convert requirements (often written in English) into precise testable rules and models. These techniques find missing, inconsistent or ambiguous requirements and produce test cases that together give clear, auditable coverage of system behaviour.

Key ideas

Start with simple definitions (each bold term is defined before use).

  • Requirement: a statement describing a capability, behaviour or constraint the software must satisfy.
  • Test case: a set of inputs, execution conditions and expected results used to verify a requirement.
  • Cause: a single input condition or predicate that can be true or false (e.g. "User is logged in"). Use causes when building tables or graphs.
  • Effect: an output or action that follows from causes (e.g. "Allow access").
  • Decision table: a tabular representation that lists causes (inputs/premises) and effects (outputs/conclusions) and defines rules (columns) that map particular cause combinations to effects.
  • Cause–effect graph: a Boolean-logic graph that represents relationships (AND, OR, NOT, combinations) between causes and effects. Nodes are causes/effects and edges and operators show the logic.
  • State: a condition or situation of the system at a point in time (e.g. "Idle", "Locked").
  • Transition: a directed change from one state to another triggered by an event or condition, often producing actions.
  • State-transition diagram / model: a graph of states (nodes) and transitions (edges) used to design tests that exercise sequences of events.
  • Completeness (decision table): A decision table is complete if every possible combination of causes is represented by at least one rule (column). Formal statement: "For n binary causes there are 2^n possible cause-combinations; completeness requires at least one column for each combination or a default rule that covers remaining combinations."
  • Consistency (decision table): A decision table is consistent if no two rules prescribe contradictory effects for the same cause-combination. Formal: "No two columns with identical cause assignments produce different outputs."
  • Coverage criterion (for tables/graphs/state models): A formal rule that picks which rules, combinations, or paths must be exercised by tests (examples: rule coverage, cause coverage, effect coverage, all-states coverage, all-transitions coverage, transition-pair/2-switch coverage, and MC/DC for logical decisions).

Exact procedure (universities ask for step-by-step):

  1. Identify and list all causes (inputs/conditions) and all effects (outputs/actions) from requirements.
  2. Build the cause–effect graph if logic is complex: connect causes to effects with AND/OR/NOT nodes and record constraints (e.g. mutual exclusion).
  3. Convert the graph to a decision table: each column is a rule giving values (Y/N/X) for each cause and resulting effects.
    • Use Y = true, N = false, X = don't care.
  4. Check the table for completeness and consistency. Add default rules or split causes if needed. Eliminate impossible combinations using stated constraints (mark '-' for impossible in the table and remove/prune such columns).
  5. Reduce the table if permitted (combine columns with identical effects) but record reductions.
  6. Generate test cases: each table column becomes at least one test case (apply input values of causes and check effects).
  7. For state behaviour, construct a state-transition diagram from requirements: nodes = states, labeled arrows = transitions with event/guard/action. Derive tests that cover transitions, states and sequences required by coverage criterion.

What to draw (diagram instructions for exams):

  • Decision table: Draw a rectangle divided horizontally. Top section: list causes as rows; bottom: list effects as rows; columns: rules numbered 1..m. In each cause row and column put Y/N/X. In each effect row and column put action trigger (Y) or blank (N).
  • Cause–effect graph: Draw circles for causes (label C1, C2...), circles or rounded boxes for effects (E1...), between them place AND (•), OR (+), and NOT (¬) operator nodes; draw directed edges from causes through operators to effects. Mark constraints: e.g. 'requires' (R), 'mutually exclusive/at most one' (E), 'one and only one' (O); if your notation lacks symbols, use a crossed arc or an explicit note such as "mutually exclusive: C2, C3".
  • State-transition diagram: Draw a circle for each state with state name inside. Draw directed arrows for transitions; label each arrow with "event [guard] / action" (guards optional). Mark initial state with an incoming arrow from a solid dot labelled Start.

Assumptions to state explicitly in exam answers: causes are binary unless stated otherwise; events are atomic; time and concurrency ignored unless the spec mentions them. For logical expressions, assume operator precedence NOT > AND > OR unless parentheses are given.

Formulas

(For this topic we list compact syntaxes and coverage counts.)

Number of possible cause-combinations = 2^n — n is number of binary causes, unitless; use when deciding completeness. For non-binary causes with cardinalities k1..kn: total combinations = ∏ k_i.

Rule (column) := {C1=v1, C2=v2, ..., Cn=vn} -> {E1=w1, E2=w2, ...} — vi ∈ {Y,N,X}, wi ∈ {trigger, no-trigger}; a textual syntax to remember when writing tables.

StateModel := (S, Σ, δ, s0, F) — S = set of states, Σ = set of events/inputs, δ = transition function S×Σ→S (or set of labeled edges), s0 = initial state, F = final/accepting states (if any). Use when you must give a formal model.

TestSuiteSize (basic) ≥ number of unique table columns after reduction — a rule of thumb for lower bound.

Worked examples

Example 1 — Decision table for ATM PIN entry (simple): Problem: ATM allows 3 attempts. If correct PIN -> Access granted. If incorrect and attempts <3 -> Prompt retry. If incorrect and attempts =3 -> Card retained.

  1. Identify causes and effects.

    • Causes: C1 = PIN correct? (binary). C2 = Attempt number = 3? (binary).
    • Effects: E1 = Grant access. E2 = Prompt retry. E3 = Retain card.
  2. Build table. There are 2^2 = 4 combinations. Columns and values:

    • Rule 1: C1=Y, C2=N -> E1=Yes, E2=No, E3=No
    • Rule 2: C1=Y, C2=Y -> E1=Yes, E2=No, E3=No (same as R1)
    • Rule 3: C1=N, C2=N -> E1=No, E2=Yes, E3=No
    • Rule 4: C1=N, C2=Y -> E1=No, E2=No, E3=Yes
  3. Reduce: Rules 1 and 2 identical in effects -> combine to one rule with C2 = X.

  4. Test cases (columns after reduction):

    • TC1: PIN correct, attempts any -> expect Access granted. (Check login success path)
    • TC2: PIN wrong, attempts < 3 -> expect Prompt retry.
    • TC3: PIN wrong, attempts = 3 -> expect Card retained.

Final answers (bold as requested in instructions are only allowed in markdown): TC1 expect Access granted; TC2 expect Prompt retry; TC3 expect Card retained.

Example 2 — State-transition trace for a simple door controller States: S = {Closed, Open, Locked}. Initial s0 = Closed. Events: e1 = open-request, e2 = close-request, e3 = lock, e4 = unlock. Transitions (δ): Closed --open-request--> Open; Open --close-request--> Closed; Closed --lock--> Locked; Locked --unlock--> Closed.

Trace test: input sequence = [open-request, close-request, lock, unlock] Step-by-step:

  1. Start in Closed.
  2. open-request => transition to Open. (Check: Open reached)
  3. close-request => transition to Closed. (Check: Closed reached)
  4. lock => transition to Locked. (Check: Locked reached)
  5. unlock => transition to Closed. (Check: Closed reached)

Expected final state: Closed. Each transition is exercised once (all-transitions coverage).

Example 3 — Cause–effect graph for discount rule Requirement: If customer is loyal AND order over 1000 OR is a promotion code, then apply discount.

  1. Causes: C1 = loyal-customer, C2 = order>1000, C3 = promo-code.
  2. Effect: E1 = apply-discount.
  3. Graph: (C1 AND C2) OR C3 -> E1. Convert to truth table (columns):
    • C1=Y,C2=Y,C3=N -> E1=Y
    • C1=Y,C2=Y,C3=Y -> E1=Y
    • C1=Y,C2=N,C3=Y -> E1=Y
    • C1=N,C2=Y,C3=Y -> E1=Y
    • C1=N,C2=N,C3=Y -> E1=Y
    • All other combinations -> E1=N

Test cases derived: combinations that make E1 true plus one that makes it false.

Common mistakes

  • Not reducing identical columns or failing to record reductions and justification.
  • Confusing a state with a transition; drawing transitions as states in diagrams.
  • Not labelling transitions with event/guard/action (required in exam diagrams).
  • Assuming independence of causes when constraints (mutual exclusion) exist.
  • For cause–effect graphs forgetting to convert NOT/AND/OR nodes correctly when making the decision table.
  • Not stating assumptions (e.g., causes are independent, discrete, atomic) in answers.

For your exam

Typical question types: definitions (define decision table, cause, effect, completeness), short notes (method steps, advantages), derivations (convert a cause–effect graph to a table), diagram drawing (draw state-transition diagram from text), test-case generation (list test cases and justify coverage), and small proofs of completeness/consistency.

What a full-marks answer includes:

  • Clear definitions of key terms used.
  • A step-by-step method applied to given requirements.
  • Correct diagrams with labels: decision table properly formatted; cause–effect graph with operator nodes; state diagram with start marker and transition labels (event [guard] / action).
  • Proof or claim about completeness/consistency with brief justification (count combinations, or show matching columns).
  • At least one test case per independent rule or required coverage criterion, with expected results.
  • Explicit assumptions.

Quick check

  1. What is a decision table in testing?
  2. How many cause-combinations for 5 binary causes?
  3. In a state diagram, what three labels should appear on a transition arrow if required by the spec?

Answers: 1) A tabular representation mapping causes to effects, 2) 32, 3) event [guard] / action

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?