Pairwise Test Case Generator

pairwise-test-case-generator

Combines boundary values, equivalence classes and pairwise (or N-wise) reduction into parameterized cases in the project's runner format.

When to use

Use when a function or endpoint takes 3 or more inputs whose combinations matter and the full Cartesian product is too large.

/plugin install qa-test-data@testland-qa

First time in Claude Code? Add the marketplace with /plugin marketplace add testland/qa

View source (opens in a new tab)
Skill
Category
Foundations
Version
v1.4.13
Updated
December 2, 2026

Overview

When a function takes multiple inputs whose interactions matter, the naive test set is the Cartesian product: 4 roles × 4 tiers × 5 features × 6 locales = 480 tests. Most teams give up before authoring all 480 and end up with happy-path-only coverage that misses interaction bugs.

The fix is all-pairs (pairwise) testing - pick a smaller test set that covers every pair of input values across the full matrix. Empirically, 2-wise coverage finds the majority of interaction bugs at a fraction of the test count. ISTQB catalogues this technique as pairwise testing (opens in new window), "a black-box test technique in which test conditions are pairs of parameter-value pairs" (commonly also called all-pairs testing).

This skill takes a multi-input spec and emits a reduced test set covering 1-wise / 2-wise / N-wise combinations.

When to use

  • A function / endpoint takes 3 or more enumerable inputs (roles, tiers, statuses, feature flags, locales).
  • Cartesian product would produce >100 tests.
  • Pairs of inputs interact (e.g. tier=enterprise + feature=sso has a different code path than tier=free + feature=sso).
  • Existing tests cover only a few hand-picked combinations - the team wants systematic coverage.

If only one input has multiple values, use boundary-value-generator instead - boundary analysis is the right tool for single-input testing.

How to use

  1. Confirm the target takes 3+ interacting inputs whose Cartesian product exceeds ~100 tests.
  2. Pick a coverage strength (default 2-wise; go 3-wise only after a triplet bug slips through).
  3. Choose the reduction tool (default PICT; AllPairs for pytest-native, NIST ACTS for a GUI or up to 6-way).
  4. Author the input spec in YAML: each input's name and values, plus domain constraints.
  5. Run the tool to compute the reduced set and emit it in your runner's parametrize format.
  6. Read the coverage report - every allowed pair is covered; check that the excluded pairs are exactly the ones your constraints intend.
  7. Commit the spec to git as the source of truth; regenerate cases whenever a value or rule changes.

Step 1 - Pick the coverage strength

StrengthCoverage
1-wiseEvery individual value of every input appears in at least one test.
2-wise (pairwise)Every pair of values across two inputs appears together.
3-wiseEvery triplet of values across three inputs appears together.
N-wiseEvery N-tuple appears.
StrengthTest count for 4×4×5×6 input space (480 max)Notes
1-wise6Just touches every value once.
2-wise~30Standard recommendation; finds most interaction bugs.
3-wise~120Use when triplet interactions matter (e.g. role × tier × feature).
Cartesian480Use only for small input spaces (≤4 inputs, ≤3 values each).

Default: 2-wise. Promote to 3-wise only when an incident postmortem shows a triplet bug slipped through 2-wise.

Step 2 - Pick the tool that computes the reduced set

ToolLanguageNotes
PICTStandaloneMicrosoft's canonical pairwise tool; CLI; deterministic output.
AllPairsPythonLibrary; integrates with pytest.
ACTSJava (GUI + CLI jar)NIST's free covering-array generator; 1-way to 6-way, constraints in the advanced version.

Default: PICT - language-agnostic CLI, deterministic CSV output that any test runner can parametrize. Use AllPairs when the spec needs to live in Python alongside pytest fixtures; use ACTS when the team wants a GUI or strengths above 3 with constraints.

Step 3 - Author the input specification

A YAML format the skill consumes:

inputs:
  - name: role
    values: [admin, manager, standard, read_only]
  - name: tier
    values: [free, starter, pro, enterprise]
  - name: feature
    values: [sso, audit_log, api_access, custom_branding, support_priority]
  - name: locale
    values: [en-US, ja-JP, de-DE, ar-SA, fr-FR, pt-BR]

strength: 2
constraints:
  # Mutually exclusive combinations (suppress these from generation):
  - "tier=free AND feature=sso"          # SSO is paid-only
  - "tier=free AND feature=audit_log"    # Audit log is paid-only

constraints exclude combinations that don't make sense in the domain - including them would generate tests for impossible states.

Step 4 - Emit in the test-runner-native format

The reduced set is emitted in the runner's native parametrize format - PICT-style CSV, pytest @pytest.mark.parametrize, Jest / Vitest test.each, or xUnit [Theory] + [MemberData]. Copy-paste-ready snippets for each format: references/output-formats.md.

Step 5 - Verify coverage

After generation, the skill emits a coverage report:

## Coverage report - strength 2

**Inputs:** 4 (role × 4 values, tier × 4 values, feature × 5 values, locale × 6 values)
**Cartesian total:** 480 cases
**Generated cases:** 30
**Constraints suppressed:** 48 of the 480 combinations (tier=free × {sso,audit_log} × 4 roles × 6 locales)

### Pair coverage matrix

| Pair                    | Allowed | Covered | Coverage |
|-------------------------|---------:|--------:|---------:|
| role × tier              |       16 |      16 |    100%  |
| role × feature           |       20 |      20 |    100%  |
| role × locale            |       24 |      24 |    100%  |
| tier × feature           |  18 (of 20) |      18 |    100%  |
| tier × locale            |       24 |      24 |    100%  |
| feature × locale         |       30 |      30 |    100%  |

### Excluded by constraints (impossible, not gaps)

- (tier=free, feature=sso)
- (tier=free, feature=audit_log)

PICT covers every allowed pair: its docs state "PICT guarantees that all possible pairs of valid (or in-range) values will be covered", and disallowed combinations are eliminated during generation (pict-doc (opens in new window)). So the review is of the exclusion list: a pair missing from the report that the domain allows means a constraint is wrong, not that the strength is too low.

Worked example

A capability check takes four inputs: role (4 values), tier (4), feature (5), and locale (6). The Cartesian product is 4 × 4 × 5 × 6 = 480 tests - too many to author or run per commit.

Author the spec with the two paid-only constraints, set strength: 2, and run PICT. It returns ~30 cases covering every allowed value pair, with the 48 impossible combinations (tier=free × {sso, audit_log} × every role and locale) suppressed. The coverage report confirms 100% coverage of all 132 allowed pairs and lists the two pairs the constraints exclude (tier=free × sso, tier=free × audit_log) for review. Result: interaction coverage from 30 tests instead of 480, checked into git as the parametrize table.

Anti-patterns

Anti-patternWhy it failsFix
Cartesian product test set when input count > 3Tests grow combinatorially; CI time explodes; flaky.Use 2-wise; promote to 3-wise per incident.
Skipping constraints for impossible combinationsTests fail for the wrong reason - testing tier=free + sso, which the system rejects.Always declare domain constraints upfront.
Hard-coded test list maintained by handCombinatorial set is fragile; adding one input value 2x's the test count.Generate from the spec; check the spec into git.
Failing to update the spec when business rules changeTest set drifts from production reality.Spec is the source of truth; reviewers reject PRs that update tests without updating the spec.
Using 1-wise as the defaultMisses every interaction bug; trivially covers single-input behavior.2-wise minimum; 1-wise only for inputs known not to interact.

Limitations

  • Pairwise misses N-tuple bugs. A bug that requires a specific triplet to manifest won't be caught by 2-wise alone. Promote to 3-wise on incident.
  • Constraint logic must be encoded explicitly. The tool can't infer "free tier doesn't have SSO" - the spec must say so.
  • Parameterized tests can hide failure attribution. When one case in 30 fails, the report should clearly identify which combination failed; many runners do this well, some don't. Verify your runner's parameterized output is informative.

References

  • ISTQB pairwise testing (opens in new window) - canonical definition of the technique this skill applies.
  • PICT - https://github.com/microsoft/pict
  • PICT usage guide (constraints, coverage guarantee, determinism) - https://github.com/microsoft/pict/blob/main/doc/pict.md
  • AllPairs (Python) - https://pypi.org/project/allpairspy/
  • NIST ACTS - https://csrc.nist.gov/projects/automated-combinatorial-testing-for-software ; user guide (1-way to 6-way, CLI and GUI jar, constraints) - https://csrc.nist.gov/csrc/media/Projects/automated-combinatorial-testing-for-software/documents/acts_user_guide_for_basic1.0_and_advanced3.3_versions_nov23.pdf
  • boundary-value-generator - sibling skill for single-input boundary cases.
  • negative-test-generator - sibling skill for rejection-path coverage.

Reference detail for pairwise-test-case-generator (opens in new window): the reduced case set emitted in each test-runner-native parametrize format.

Pairwise CSV (PICT-style)

role,tier,feature,locale
admin,free,api_access,en-US
admin,starter,sso,ja-JP
admin,pro,audit_log,de-DE
admin,enterprise,custom_branding,ar-SA
manager,free,api_access,fr-FR
manager,starter,sso,pt-BR
...

pytest

import pytest

CASES = [
    ("admin", "free", "api_access", "en-US"),
    ("admin", "starter", "sso", "ja-JP"),
    ("admin", "pro", "audit_log", "de-DE"),
    # ... ~30 cases for 2-wise of the 4×4×5×6 space
]

@pytest.mark.parametrize("role,tier,feature,locale", CASES)
def test_user_capability(role, tier, feature, locale):
    result = check_capability(role=role, tier=tier, feature=feature, locale=locale)
    assert result.allowed in (True, False)   # specific assertion per the business rules

Jest / Vitest

const cases = [
  ['admin', 'free', 'api_access', 'en-US'],
  ['admin', 'starter', 'sso', 'ja-JP'],
  // ...
];

test.each(cases)(
  'role=%s tier=%s feature=%s locale=%s',
  (role, tier, feature, locale) => {
    const result = checkCapability({ role, tier, feature, locale });
    expect(typeof result.allowed).toBe('boolean');
  }
);

xUnit (.NET)

public static IEnumerable<object[]> Cases =>
    new List<object[]>
    {
        new object[] { "admin",   "free",     "api_access",      "en-US" },
        new object[] { "admin",   "starter",  "sso",             "ja-JP" },
        // ...
    };

[Theory]
[MemberData(nameof(Cases))]
public void UserCapability(string role, string tier, string feature, string locale)
{
    var result = CheckCapability(role, tier, feature, locale);
    Assert.IsType<bool>(result.Allowed);
}
  • Nightly export suite runs three combinations and keeps missing bugs
  • Close postmortem action AI-3: the permission matrix missed INC-2291
  • Add the Team plan to entitlements and its test table

Get new posts by email.

Occasional email with new Testland posts and plugin releases.

Unsubscribe any time. Privacy policy