Skip to content
Tutorials Center
My learning

Topics

Lesson 16 of 60 ยท Test Design Techniques

Cause-Effect Graphing

Learn cause-effect graphing: model causes and effects with AND, OR and NOT, add constraints, and turn the graph into a decision table and test cases.

Decision tables work well when a feature has a handful of conditions. When a requirement reads like a wall of "if this and not that, or the other, then both A and B", the table grows quickly and it is easy to miss rules or contradict yourself. Cause-effect graphing is a black-box technique for exactly that: you turn the text into a small Boolean network of causes (inputs or conditions) and effects (outputs or actions), and then derive tests from the graph.

It is a rigorous cousin of the decision table. In practice, the graph is a thinking aid and the decision table it generates is the real test design.

The ingredients

  • Cause: an input condition or an event, such as "user is a member". It is either true or false.
  • Effect: an output or system change, such as "discount applied". It is either present or absent.
  • Intermediate node: a combination of causes used to simplify the graph.

Each cause and effect gets a short ID (C1, C2, E1) so the graph stays readable.

The four basic relationships

Using Boolean logic, the graph connects nodes with four notations:

Relationship Meaning
Identity If the cause is true, the effect is true.
NOT (~) If the cause is true, the effect is false (and vice versa).
AND (^) The effect is true only if all connected causes are true.
OR (v) The effect is true if at least one connected cause is true.

Constraints between causes

Real inputs are not independent. A form cannot have both "adult" and "child" ticked. Constraints record such facts so you do not waste tests on impossible combinations. The classic ones:

  • E (exclusive): at most one of the causes can be true.
  • I (inclusive): at least one must be true.
  • O (one and only one): exactly one is true.
  • R (requires): if cause A is true, cause B must also be true.
  • M (mask) on effects: if effect A is true, effect B is forced false.

The process in six steps

  1. Read the specification and split it into pieces small enough to graph.
  2. List the causes and effects and give each an ID.
  3. Draw the graph: connect causes to effects with the four relationships, using intermediate nodes where helpful.
  4. Add constraints for impossible or forced combinations.
  5. Convert the graph into a limited-entry decision table: for each effect, work backwards to find which combinations of causes make it true.
  6. Turn each column of the table into a test case with concrete data and expected results.
flowchart LR
  C1["C1: member"] --> A1(("AND"))
  C2["C2: cart over 100"] --> A1
  A1 --> E1["E1: 10 percent off"]
  C3["C3: coupon valid"] --> O1(("OR"))
  A1 --> O1
  O1 --> E2["E2: free shipping"]

A graph for a small shop rule. Member AND cart over 100 gives the discount; either the discount or a valid coupon gives free shipping.

A worked example

The requirement: "Members whose cart is over 100 get 10 percent off. Free shipping is given when the customer got the discount or has a valid coupon. Guests cannot use member discounts."

Causes: C1 = member, C2 = cart over 100, C3 = valid coupon. Effects: E1 = discount applied, E2 = free shipping.

Boolean rules read off the graph:

  • E1 = C1 AND C2
  • E2 = E1 OR C3

With three causes there are only 8 combinations, and the rules give the full decision table below.

Test C1 member C2 over 100 C3 coupon E1 discount E2 free shipping
1 T T T yes yes
2 T T F yes yes
3 T F T no yes
4 T F F no no
5 F T T no yes
6 F T F no no
7 F F T no yes
8 F F F no no

For many graphs, you do not need all rows. A reduction heuristic: to make an AND effect true, set all its causes true (one test); to make it false, test each cause false while the others are true. For OR, make it false with all causes false, and true with each cause true alone. That cuts the rows while keeping the ability to detect a wrong operator or a missing condition.

Try it: generate the table from the rules

Let a program do the boring part. This stand-in enumerates every cause combination, evaluates the rules from the graph and prints the decision table. A constraint is also encoded.

JS Generate a decision table from cause-effect rules

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Change an operator in freeShipping from || to && and see how the table changes. That is the kind of mistake a good set of tests from the graph catches.

Try it: check an implementation against the table

Now the other direction: use the rules as a test oracle against a buggy implementation, running all combinations and listing mismatches.

JS Use the graph as an oracle

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Strengths and limits

Cause-effect graphing helps you:

  • find ambiguity and gaps in a requirement while drawing it (a form of static testing);
  • cover combinations of conditions systematically;
  • produce a justified, minimal test set.

It is heavier than other techniques. It suits logic-heavy rules (insurance, tax, eligibility, access control) but not simple forms. With many causes, the number of combinations explodes, so reduce with the heuristics above, or combine with pairwise testing.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. In a cause-effect graph, what is an effect?

    Causes are inputs or conditions; effects are the outputs or actions that result.
  2. 2. Effect E = C1 AND C2. How many of the four combinations of C1 and C2 make E true?

    AND is true only when both causes are true, which is exactly one of the four combinations.
  3. 3. Why add constraints such as 'exclusive' to a graph?

    Constraints describe combinations that cannot happen, so you do not write meaningless tests.
  4. 4. What is the usual final output of cause-effect graphing?

    The graph is converted into a limited-entry decision table, and each column becomes a test case.

Summary

  • Cause-effect graphing models inputs (causes) and outputs (effects) with identity, NOT, AND and OR.
  • Constraints (exclusive, inclusive, one-and-only-one, requires, mask) remove impossible combinations.
  • The graph becomes a decision table, and the table becomes test cases.
  • It excels at logic-heavy rules and exposes ambiguity early; reduce rows with heuristics when there are many causes.

Next up: State Transition Testing.