Skip to content
Bugwise
Menu
Testing Fundamentals

Pairwise Testing

Why combinations explode, how all-pairs testing covers every pair of values with a fraction of the tests, what it can't catch, how constraints and tools like PICT work, and when to use it.

intermediate Mobile & web
Short on time? Switch to the quick version.

An online shop is about to launch in three countries. The test lead lists what checkout must work with: 4 browsers, 4 operating systems, 3 languages and 3 payment methods. A new tester multiplies: 4 × 4 × 3 × 3 = 144 combinations. At 10 minutes each, that’s 24 hours of clicking through checkout, for one feature, before every release.

Nobody does that. But testing a random handful isn’t great either: the one bug that matters (“PayPal button missing in German on Firefox”) could hide in a combination nobody picked. Pairwise testing gives you a small, smart set instead, typically 16 to 18 tests here, with a guarantee you can check.

Each thing you can vary (browser, operating system, language, payment method) is a parameter, and the options for it (Chrome, Safari…) are its values. In a decision table these were the conditions; a parameter is the same idea, but it often has more than two values.

This lesson is a step up from the earlier ones. On a first pass, the Quick version is enough; come back to Detailed later.

Part Not started

What is pairwise testing?

Pairwise testingPairwise testingChoosing a small set of tests so that every pair of input values appears together at least once.Open in glossary → (also called all-pairs testing) picks a set of tests in which every pair of values from any two parameters appears together at least once. Not every full combination, just every pair.

Why pairs? Because studies of real failures (notably by the US National Institute of Standards and Technology, NIST) found that most bugs are triggered by a single value or by two values interacting, and progressively fewer need three or more specific values at once. Covering every pair catches the large group cheaply.

A tiny example

Three parameters with two values each give 2 × 2 × 2 = 8 combinations. These 4 rows already contain every pair:

OSLanguagePayment
iOSEnglishCard
iOSGermanPayPal
AndroidEnglishPayPal
AndroidGermanCard

Check any two columns: iOS + English, iOS + German, Android + English, Android + German all appear. The same holds for OS + Payment and Language + Payment.

Check this part

  1. What does a pairwise (all-pairs) test set guarantee?

  2. Why is covering pairs usually enough to catch a lot of bugs?

A small set of tests in which every pair of values from any two parameters appears together at least once.

Part Not started

The combinatorial explosion

Every parameter multiplies the number of combinations. This is the combinatorial explosionCombinatorial explosionThe rapid growth in the number of combinations as conditions are added.Open in glossary →: 4 × 4 × 3 × 3 = 144. Add a fifth parameter with 4 values and it’s 576. Pairwise testing grows much more slowly: the minimum is roughly the product of the two largest parameters (here 4 × 4 = 16).

When parameters are independent, the number of full combinations is the product of their value counts. That’s the combinatorial explosionCombinatorial explosionThe rapid growth in the number of combinations as conditions are added.Open in glossary →:

ParametersValuesAll combinations
Browser, OS4 × 416
+ Language× 348
+ Payment× 3144
+ Account (guest / signed in)× 2288
+ Currency (3)× 3864

Meanwhile, the number of pairs grows gently, because you only add the pairs of the new parameter with each existing one. And a pairwise set can’t be smaller than the two largest parameters multiplied (every Browser + OS pair needs its own row), so with 4 browsers and 4 systems you need at least 16 rows however many 2- or 3-value parameters you add.

How to count the pairs

To know what “all pairs” means, count them: for every two parameters, multiply their value counts, then add everything up. For Browser (4), OS (4), Language (3), Payment (3):

Parameter pairPairs
Browser + OS4 × 4 = 16
Browser + Language4 × 3 = 12
Browser + Payment4 × 3 = 12
OS + Language4 × 3 = 12
OS + Payment4 × 3 = 12
Language + Payment3 × 3 = 9
Total73 pairs

Each test row covers 6 pairs at once (one per parameter pair). So 73 pairs need at least 73 ÷ 6 ≈ 13 rows in theory, and the Browser + OS minimum pushes that to 16. Good tools land at or close to 16; the simple generator in the lab below finds 18.

Check this part

  1. Browser (4 values), OS (4), Language (3) and Payment (3). How many full combinations are there?

  2. For the same model, what is the smallest possible number of pairwise tests?

Every parameter multiplies the combinations, while a pairwise set grows slowly from the two largest parameters multiplied.

Part Not started

Constraints: impossible and unwanted combinations

Some combinations can’t exist: Safari doesn’t run on Windows. If you just delete such a row, the pairs it covered end up untested. Constraints tell the tool what’s impossible up front, so it covers every valid pair with rows you can actually run. Only exclude what truly can’t happen: every constraint removes pairs.

Without constraints, a generator happily produces “Safari on Windows” rows. You can’t run them, and the pairs they were supposed to cover (say, Safari + German) end up untested if you just delete the row. Constraints tell the tool what’s impossible up front, so it covers every valid pair with valid rows.

Be careful in the other direction too: every constraint removes pairs. Constraining “Apple Pay only with Safari” would hide a real bug where Apple Pay fails in Chrome on a Mac. Only exclude what truly can’t happen.

A worked example: checkout across browsers, OS, languages and payments

  1. List the parameters and choose values with equivalence partitioning. Browser: Chrome, Safari, Firefox, Edge. OS: Windows, macOS, Android, iOS. Language: English, German, Spanish. Payment: Card, PayPal, Apple Pay. Each value should represent a class that might behave differently.
  2. Add constraints for combinations that can’t exist: Safari runs only on macOS and iOS; in this shop, Apple Pay is offered only on Apple devices.
  3. Generate the set with a tool. Without constraints you get about 16 to 18 rows; with them, a few pairs disappear (Safari + Windows is no longer required) and the set gets slightly smaller.
  4. Check coverage. Good tools guarantee it; if you build or edit a set by hand, verify that every allowed pair appears at least once.
  5. Add risk-based rows on top. Your analytics say 40% of customers use Chrome on Android in English with Card? Make sure that exact row exists, even if pairwise didn’t produce it.
  6. Give every row an expected result. Pairwise picks the inputs; you still define what “correct” looks like, ideally with the same checkout test case run on each row.

Try exactly this in the lab below: turn the constraints on and off and watch the numbers change.

Check this part

  1. Why do you add constraints such as "Safari only on macOS and iOS"?

  2. Apple Pay works in Chrome on a Mac. Should you add the constraint "Apple Pay only with Safari" to save a few rows?

Constraints tell the tool which combinations can't exist, so every valid pair lands in a row you can run.

Part ProNot started

What pairwise doesn’t catch

  • Three-way bugs that need three specific values together (German + PayPal + Firefox).
  • Choosing good values is still your job: use equivalence partitioning first.
  • Expected results: it tells you what to run, not what is correct.
  • Higher-order interactions. A bug that needs German and PayPal and Firefox together appears only if that triple happens to land in one row. Pairwise doesn’t promise it. For risky features, tools can generate 3-way (or higher) coverage at the cost of more rows.
  • Bad value choices. If you list “Chrome, Firefox” but forget mobile Safari, no algorithm will test mobile Safari.
  • Rule-based behavior. When the result depends on specific combinations (members on rainy days pay €1), you need every rule tested: use a decision table.
  • Order and timing. Pairwise picks values, not sequences. For flows over time, see state transition testing.
  • The expected results. It tells you what to run, not what’s right.

Check this part

  1. A bug only appears with German, PayPal and Firefox together. Will pairwise testing catch it?

  2. You list the browsers "Chrome, Firefox" and forget mobile Safari. What happens?

Pairwise doesn't promise three-way bugs, can't pick good values for you, and doesn't tell you the expected results.

The rest of this lesson is in Bugwise Pro

The last parts of every lesson are part of Bugwise Pro. Sign in to unlock them if you have it.

Part ProNot started

Tools, and when to use pairwise testing

Tools

You don’t build pairwise sets by hand. PICT, Microsoft’s free command-line tool (a program you run by typing a command instead of clicking), takes a simple text file of parameters, values and constraints and prints the test rows.

When to use it

Many independent parameters with several values each: browsers × OS × language, settings screens, configuration and device matrices, forms with many optional fields. If the outcome follows rules about specific combinations, use a decision table instead.

Tools: PICT and friends

PICTPICTPairwise Independent Combinatorial Testing: Microsoft's free command-line tool that generates pairwise test sets.Open in glossary → (Pairwise Independent Combinatorial Testing) is a free command-line tool from Microsoft (a program you run by typing a command instead of clicking), available on GitHub. You write a plain text model file:

Browser:  Chrome, Safari, Firefox, Edge
OS:       Windows, macOS, Android, iOS
Language: English, German, Spanish
Payment:  Card, PayPal, Apple Pay

IF [Browser] = "Safari"    THEN [OS] IN {"macOS", "iOS"};
IF [Payment] = "Apple Pay" THEN [OS] IN {"macOS", "iOS"};

Then run pict checkout.txt and it prints one test per line, tab-separated, ready to paste into a spreadsheet or test management tool. A few useful options:

  • /o:3 generates 3-way coverage instead of pairs (the default order is 2).
  • /r randomizes the generation, so different runs give different sets with the same pair coverage.
  • Values marked with ~ are treated as invalid (negative) values, and PICT puts at most one of them in each row, so a failing value doesn’t hide another.

Other options include NIST’s ACTS tool and many online pairwise generators. Whatever you use, the input is the same thinking: parameters, values, constraints.

When to use pairwise testing

Good fits:

Poor fits:

  • Two parameters: pairwise = all combinations, there’s nothing to save.
  • Business rules about specific combinations: decision tables.
  • Safety- or money-critical combinations you can list: test them explicitly, and consider 3-way coverage.

Check this part

  1. Which situation fits a decision table better than pairwise testing?

  2. What does PICT do?

Tools like PICT generate the rows; pairwise fits many independent parameters, decision tables fit rules about specific combinations.

The rest of this lesson is in Bugwise Pro

The last parts of every lesson are part of Bugwise Pro. Sign in to unlock them if you have it.

Try it: the pairwise lab

Pick parameters and values, compare every combination with the pairwise set, and switch on Show which pairs each row covers. Then remove a row with × and watch the coverage check list the pairs you just lost.

🧮 Pairwise lab

Pick the parameters and values for a web shop's checkout test. Compare testing every combination with a set where every pair of values appears at least once.

1. Parameters and values

Every combination

144

4 × 4 × 3 × 3

Pairwise set

18 tests

73 pairs to cover

Size compared with all

12.5% of all combinations

Coverage check: 73 of 73 pairs covered by 18 rows. Every pair appears at least once.

The check recomputes every pair that can occur and looks for it in the table. Remove a row (×) to see what breaks.

#BrowserOSLanguagePaymentRemove row
1ChromeWindowsEnglishCard
2ChromemacOSGermanPayPal
3ChromeAndroidSpanishApple Pay
4SafariWindowsGermanApple Pay
5SafarimacOSSpanishCard
6SafariAndroidEnglishPayPal
7FirefoxWindowsSpanishPayPal
8FirefoxmacOSEnglishApple Pay
9FirefoxAndroidGermanCard
10EdgeiOSEnglishCard
11EdgeiOSGermanPayPal
12EdgeiOSSpanishApple Pay
13ChromeiOSEnglishCard
14SafariiOSEnglishCard
15FirefoxiOSEnglishCard
16EdgeWindowsEnglishCard
17EdgemacOSEnglishCard
18EdgeAndroidEnglishCard

Generated with a simple greedy algorithm: it keeps adding the allowed combination that covers the most untested pairs. Real tools like PICT use smarter strategies, but the idea is the same.

Practice: a fitness app’s settings

A fitness app wants its workout summary tested across these settings:

  • Units: metric, imperial
  • Theme: light, dark, system
  • Language: English, Spanish, Polish
  • Watch connected: yes, no
  1. Count all combinations.
  2. Find the pairwise minimum from the two largest parameters.
  3. Count the pairs the set has to cover.
  4. Write a pairwise set with as few rows as you can.
  5. Add a risk-based row. Most users are on metric, system theme, English, watch connected: make sure that exact row is in the set.
Show the answer
  1. All combinations: 2 × 3 × 3 × 2 = 36.
  2. The two largest parameters are Theme and Language: 3 × 3 = 9 rows at least.
  3. Units + Theme 6, Units + Language 6, Units + Watch 4, Theme + Language 9, Theme + Watch 6, Language + Watch 6 = 37 pairs.
  4. One possible set of 9 rows that covers all 37 pairs:
UnitsThemeLanguageWatch connected
MetricLightEnglishYes
ImperialLightSpanishYes
MetricLightPolishNo
ImperialDarkEnglishNo
MetricDarkSpanishYes
MetricDarkPolishYes
MetricSystemEnglishYes
MetricSystemSpanishNo
ImperialSystemPolishYes
  1. The risk-based row (Metric, System, English, Yes) is already row 7 here. If your set doesn’t contain it, add it as an extra row.

The lab doesn’t have this exact model, but you can see the same effect: switch off Account, keep three parameters with a few values each and compare the row count with the product of the two largest parameters.

Key takeaways

  • Combinations multiply; testing all of them quickly becomes impossible (the combinatorial explosion).
  • Pairwise (all-pairs) testing covers every pair of values at least once, with a minimum of roughly the two largest parameters multiplied.
  • Most real failures involve one or two interacting values, so pairs catch a lot cheaply, but not three-way bugs.
  • Add constraints for impossible combinations, and risk-based rows for combinations that matter most.
  • Choose values with equivalence partitioning, and still define an expected result for every row.
  • Use a tool like PICT to generate sets; use decision tables when rules depend on specific combinations.

Finished this page?Nice work, this page is complete!

Mark it as done to track your progress. It's saved in this browser, no account needed.

Its cards are now in your Bites review ⚡
Esc

Type to search the whole site.