The idea: test every pair, not every combination
A checkout page must work on many setups. The page uses four parameters: Browser (Chrome, Firefox, Safari), OS (Win, Mac, Linux), Lang (EN, FR, VI) and Pay (Card, PayPal, Bank). Testing every combination takes 3 × 3 × 3 × 3 = 81 tests. Add one more parameter and it is 243. The count grows exponentially.
Studies of real failures found that most bugs are triggered by one value or by two values together, for example "PayPal fails in Firefox". So pairwise testing (also called all-pairs testing) asks for less: every pair of values of every two parameters must appear in at least one test. Which values the parameters get is decided first, for example with Equivalence Partitioning and Boundary Value Analysis.
Counting pairs
Four parameters make 6 parameter pairs: Browser × OS, Browser × Lang, Browser × Pay, OS × Lang, OS × Pay and Lang × Pay. Each has 3 × 3 = 9 value pairs, so there are 54 pairs. The right side of the canvas draws them as six 3 × 3 blocks.
One test, for example (Chrome, Win, EN, Card), touches one cell in each block: it covers 6 pairs. So at least 54 / 6 = 9 tests are needed. The Browser × OS block alone also needs 9 tests, one per cell. In general the two largest parameters set the lower bound: v1 × v2 tests.
Orthogonal array L9
For 4 parameters with 3 values each there is a perfect answer: the orthogonal array L9(34). Number the values 0, 1, 2. For i and j from 0 to 2, the test is (i, j, i + j mod 3, i + 2j mod 3). That gives 9 rows, and every pair appears in exactly one of them. Demo 1: orthogonal array L9.
Orthogonal arrays come from statistics (design of experiments). They exist only for some sizes, and they need every parameter to have the same number of values.
Greedy generation, one test at a time
Tools such as AETG and PICT build a suite with a greedy loop. Each round looks at the candidate tests and adds the one that covers the most pairs not covered yet. The loop stops when every pair is covered. The page tries every allowed combination as a candidate and breaks a tie by taking the first one in order (Chrome before Firefox, Win before Mac, and so on), so the result is always the same. Demo 4: greedy, one test at a time. On 4 × 3 values it finds 9 tests too, each adding 6 new pairs.
Greedy works for uneven parameters. With Lang ∈ {EN, VI} and Pay ∈ {Card, PayPal} there are 3 × 3 × 2 × 2 = 36 combinations and 9 + 6 + 6 + 6 + 6 + 4 = 37 pairs. The rounds add 6, 6, 6, 6, 4, 4, 3, 1, 1 new pairs: 9 tests, the lower bound of the 3 × 3 Browser × OS block. Demo 5: uneven 3 × 3 × 2 × 2. The last rounds add only a pair or two; that tail is typical of greedy suites.
Constraints
Some combinations cannot exist. Say Safari runs only on Mac: Safari + Win and Safari + Linux are forbidden. That removes 2 pairs (52 left) and 18 combinations (63 left).
A fixed array breaks. Two rows of L9 put Safari on Win or Linux; dropping them loses their other pairs, and only 7 tests covering 42 of 52 pairs remain. Demo 6: a constraint breaks the L9 array. The greedy loop simply never picks a forbidden candidate. It needs 11 tests for all 52 pairs, two more than without the constraint. Demo 7: constraint, greedy covers every allowed pair.
| Config | All combinations | Pairs | L9 | Greedy |
|---|---|---|---|---|
| 4 × 3 values | 81 | 54 | 9 tests, 54 / 54 | 9 tests, 54 / 54 |
| 3 × 3 × 2 × 2 | 36 | 37 | does not fit | 9 tests, 37 / 37 |
| Safari only on Mac | 63 | 52 | 7 tests, 42 / 52 | 11 tests, 52 / 52 |
What pairwise finds and what it misses
A bug that needs two values is always found, because its pair is in some test. Firefox + PayPal sits in T4 of L9: 1 of 9 tests fails. Running all 81 combinations shows 9 failures of the same bug, which tells nothing new. Demo 2: a pair bug.
A bug that needs three values can slip through. Say the checkout fails only with Firefox + Linux + VI. L9 has each of the three pairs, but in three different tests, so all 9 pass. All 81 combinations would find it in 3 tests. Demo 3: a 3-way bug.
The number of values that must meet is the interaction strength t. Pairwise is t = 2. A t-way suite (a covering array of strength t) covers every combination of t values. For a fixed t its size grows only with the logarithm of the number of parameters, so 3-way and 4-way suites are still practical when pairwise is not enough.
| Bug needs | L9 (9 tests) | All combinations (81) |
|---|---|---|
| Firefox + PayPal (2 values) | ✓ 1 of 9 fails | ✓ 9 of 81 fail |
| Firefox + Linux + VI (3 values) | ✗ missed, 0 fail | ✓ 3 of 81 fail |
Pairwise testing is a black-box technique: it chooses inputs from the parameters, not from the code. To check how much of the code the tests reach, see Control-Flow Coverage, Condition Coverage and MC/DC and Data-Flow Testing. To check whether the tests would notice a bug at all, see Mutation Testing.
What the page leaves out
The page does not cover how real generators choose candidates: AETG draws about 50 random candidates per round, and IPOG grows the suite one parameter at a time instead of one test at a time. It also leaves out mixed-strength suites (3-way for some parameters only), seeding a suite with tests that must be in it, negative values (one invalid value per test), the expected-result problem for many tests, and the exact known sizes of covering arrays. The tests never run real code: the bug is a fixed rule on the four values.