pairwise-test-coverage

Combinatorial testing with a greedy pairwise matrix generator. Covers all factor pairs in near-minimal test cases. Use when the user wants to generate a pairwise or threewise test matrix, reduce a Cartesian product, create all-pairs test cases, or asks how many test cases are needed to cover all pairs of their factors. Trigger on: 'pairwise', 'all-pairs', 'test matrix', 'combinatorial', 'factor combinations', 'threewise', 'reduce test combinations'.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "pairwise-test-coverage" with this command: npx skills add apankov1/quality-engineering/apankov1-quality-engineering-pairwise-test-coverage

Pairwise Test Coverage

Combinatorial testing that covers all factor pairs in near-minimal test cases.

When to use: Multi-factor systems where exhaustive testing is impractical, state machines, retry/recovery logic, configuration matrices, compatibility testing, any code with 3+ interacting parameters.

When not to use: Single-factor tests (just test each value), two-factor systems (test all combinations directly), UI snapshot tests, type-only changes.

Pairwise vs Model-Based

Pairwise selects which input combinations to test. Model-based testing derives which state transitions to test. Different questions, different tools:

Your system has...UseExample
Independent parameters with discrete valuesPairwiseOS × browser × locale config matrix
Named states with transitions between themModel-baseddraft → review → published workflow
State machine guards with 5+ boolean inputsBothModel-based finds the guards, pairwise covers the flag combos

Rule of thumb: if you're testing what goes in, use pairwise. If you're testing what happens next, use model-based.

What To Protect (Start Here)

Pairwise coverage protects against interaction bugs — defects that only appear when two specific factor values combine. Before generating a matrix, identify which factors interact:

DecisionQuestion to AnswerIf Yes → Use
Factor combinations cause different behaviorDo any two parameters interact to produce a unique code path?generatePairwiseMatrix
Critical factors need stronger coverageAre some factors higher-risk (auth, payment, region)?factorWeights option
Three-way interactions are plausibleCould a bug require three specific values to trigger?strength: 3 option

Do not generate tests for decisions the human hasn't confirmed. A pairwise matrix with arbitrary factors produces coverage numbers without catching bugs — the human must identify which factors actually interact.

Core Philosophy

Exhaustive testing doesn't scale. If a system has 4 factors with 3 values each, that's 81 test cases. Pairwise testing covers all pair interactions in ~12 cases -- an 85% reduction with near-complete defect detection.

Rationalizations (Do Not Skip)

RationalizationWhy It's WrongRequired Action
"We'll test the important combinations"Unexpected factor interactions go untested without systematic coverageGenerate the pairwise matrix
"81 test cases is fine"81 cases means 81 things to maintain and debug when they failUse pairwise to get 12
"The test passes, so the code works"Test must FAIL before the fix to prove it catches the bugValidate detection first

Included Utilities

// Pairwise matrix generator (zero dependencies)
import { generatePairwiseMatrix, generateThreewiseMatrix, formatAsMarkdownTable } from './pairwise.ts';

// Pairwise test case helpers
import { createPairwiseTestCases, generateTestCaseName } from './test-fixtures.ts';
// 3-wise coverage for critical paths (slower than pairwise)
const matrix3 = generatePairwiseMatrix(factors, { strength: 3 });

// Weighted scoring prioritizes high-risk factors
const weighted = generatePairwiseMatrix(factors, {
  factorWeights: { auth: 10, region: 4 },
});

Performance and Limits

The greedy algorithm never enumerates the Cartesian product. Pair count grows as O(factors² × values²).

FactorsValuesCartesianPairwise CasesTime
3327~10<1ms
8465,536~46~2ms
8816,777,216~100~10ms

Hard limits (throws if exceeded): max 20 factors, max 50 values per factor. Beyond these, pair count exceeds ~475K (C(20,2) × 50²) and in-memory generation becomes impractical.

For strength: 3, interaction growth is much faster. Use only for focused high-risk matrices (typically <= 6 factors with low cardinality).

Violation Rules

SlugRuleSeverity
missing_pairwise_coverageMulti-factor code changes need pairwise testsmust-fail
bug_detection_not_validatedTests must fail before fix, pass aftermust-fail

Definition of Done

  • Factors documented in test file header
  • Pairwise matrix as it.each test cases
  • Tests fail before fix, pass after

Companion Skills

This skill provides combinatorial test matrix generation, not test design guidance. For broader methodology:

  • Search combinatorial testing on skills.sh for constraint handling, higher-strength covering arrays, and test oracle strategies
  • Guard truth tables with 5+ boolean inputs use pairwise for coverage — use model-based-testing for state machine transition matrices and guard truth table generation
  • Zod schemas with 5+ optional fields use pairwise for compound state coverage — use zod-contract-testing for schema boundary validation and compound state matrices

Details

See references for:

  • workflow.md: Step-by-step implementation guide
  • violations.md: Full violation rules with detection patterns
  • examples.md: 6 testing technique examples (pairwise, property-based, model-based, fault injection, contract, observability)

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

breaking-change-detector

No summary provided by upstream source.

Repository SourceNeeds Review
General

barrier-concurrency-testing

No summary provided by upstream source.

Repository SourceNeeds Review
General

fault-injection-testing

No summary provided by upstream source.

Repository SourceNeeds Review
General

model-based-testing

No summary provided by upstream source.

Repository SourceNeeds Review