Relix

Problem solving

Enough cases to cover

Grain: one row per generated case · Class: Generation · Signals: enough cases, all combinations, every pair, test matrix, cover, generate then filter · Operators: COVER, × (generate)

The problem

"We test across three browsers, three operating systems and two plans. The full matrix is 18 combinations, and Safari only runs on macOS. Give me the smallest test suite that still exercises every pair of factor values — and prove it is complete."

How to recognise it

The question is about producing rows rather than filtering existing ones — enough cases, every combination, all pairs, a test matrix, generate and then narrow. The tell is a combinatorial space that explodes and a budget that cannot afford all of it. Two moves make the class:

The data

Three factors — the full space is 3 × 3 × 2 = 18.

Browser := [
| browser |
|---------|
| Chrome  |
| Firefox |
| Safari  |
];

OS := [
| os      |
|---------|
| Windows |
| macOS   |
| Linux   |
];

Plan := [
| plan |
|------|
| Free |
| Pro  |
];

Recipe 1: generate, then constrain (× and σ)

The cross product is the generator: it proposes every combination. A σ then removes the ones that cannot happen — Safari runs only on macOS:

Query
Full  := { Browser × OS × Plan };
Valid := { σ browser ≠ "Safari" ∨ os = "macOS" (Full) };
query { γ COUNT(*) → valid_combos (Valid) };
Result
 valid_combos
 ────────────
           14
(1 row)

Recipe 2: thin to a covering suite (COVER)

COVER 2 keeps a subset in which every pair of factor values still appears together at least once. Crucially, it derives the pairs it must cover from the constrained input — so the invalid combinations are never demanded, and the constraint comes for free:

Query
Suite := { COVER 2 (Valid) };
query { τ browser, os (Suite) };
Result
 browser  os       plan
 ───────  ───────  ────
 Chrome   Linux    Free
 Chrome   Windows  Free
 Chrome   macOS    Pro
 Firefox  Linux    Pro
 Firefox  Windows  Pro
 Firefox  macOS    Free
 Safari   macOS    Free
 Safari   macOS    Pro
(8 rows)

Eight cases instead of the full fourteen, yet every browser–os, browser–plan and os–plan pair is present somewhere. The τ only sorts for reading; COVER emits in selection order.

Prove it is complete, in-language. Coverage is verifiable with a difference — every pair in the valid space minus every pair in the suite is empty when the design is complete, so no external oracle is needed:

Query
query { (π browser, os (Valid)) − (π browser, os (Suite)) };
Result
 browser  os
 ───────  ──
(0 rows)
Query
query { σ browser = "Safari" (Suite) };
Result
 browser  os     plan
 ───────  ─────  ────
 Safari   macOS  Free
 Safari   macOS  Pro
(2 rows)

Variations

Pitfalls

Check it