Pairwise Testing

Pairwise testing, also called all-pairs testing, is a black-box test design technique for features that depend on several parameters, each with a few values. Instead of testing every combination, you choose tests so that every pair of values from any two parameters appears together in at least one test. A web shop supported in 3 browsers, on 3 operating systems and in 3 languages has 27 combinations, yet 9 well-chosen tests contain every browser–OS, browser–language and OS–language pair.

It builds on equivalence partitioning: partitioning gives each parameter its values, one representative per partition, and pairwise testing decides how to combine them without multiplying the number of tests.

Why it matters

Many failures appear only when two settings meet: a layout that breaks only for Arabic in Firefox, a price that is wrong only for yearly billing in US dollars. Testing each value once misses these interactions, and testing every combination is rarely possible, because the count multiplies with every parameter.

Pairwise testing is a systematic middle ground. Instead of "the configurations we usually try", the team gets a small set whose coverage can be stated and checked, such as "all 27 value pairs in 9 tests".

Why testing all combinations explodes

A parameter is anything that varies independently: browser, operating system, interface language, user role, payment method, feature flag. The number of combinations is the product of the value counts, so every new parameter multiplies the total.

At the other extreme is each choice coverage from the lesson on equivalence partitioning: every value appears in at least one test, so three tests are enough when every parameter has three values. It is cheap, but it never deliberately puts two particular values together.

  • 3 browsers × 3 operating systems × 3 languages = 27 combinations.
  • Add screen size (phone, tablet, desktop): 27 × 3 = 81.
  • Add two user roles (guest, signed-in): 81 × 2 = 162, or 27 hours at 10 minutes per manual run.
  • Ten parameters with three values each: 3^10 = 59,049 combinations.

What all-pairs coverage means

A value pair is one value of one parameter together with one value of another, for example Browser = Chrome with Language = Arabic; the ISTQB glossary calls it a pair of parameter-value pairs. Value pairs are the coverage items of this technique: pairwise coverage is the percentage of value pairs exercised by at least one test, and a pairwise set reaches 100%.

The set stays small because one test covers several pairs at once: Chrome · Windows · Arabic covers Chrome–Windows, Chrome–Arabic and Windows–Arabic. The more parameters a test has, the more pairs it covers, so a pairwise set grows slowly as parameters are added.

No set can be smaller than the value count of the largest parameter times that of the second largest: 4 browsers and 3 operating systems need at least 12 tests. Most tools use greedy algorithms that find a small set, not always the smallest; what matters is 100% pair coverage.

Parameters:        Browser (3), OS (3), Language (3)

All combinations:  3 × 3 × 3                  = 27 tests

Value pairs:       Browser–OS         3 × 3  =  9
                   Browser–Language   3 × 3  =  9
                   OS–Language        3 × 3  =  9
                   total                     = 27 pairs

Pairs in one test: 3 (one per pair of parameters)
Fewest tests:      3 × 3 (two largest)       =  9 tests
                   27 pairs / 3 per test     =  9, so each pair appears once

Try it: Pairwise Testing Generator

Worked example: browsers × operating systems × languages

A checkout page must work in Chrome, Firefox and Edge, on Windows, macOS and Linux, in English, Arabic (right to left) and Hindi. Safari is left out because it runs only on Apple platforms, so Safari–Windows is impossible; the rules that exclude such pairs, called constraints, are the subject of the lesson on combinatorial testing.

Build the set by hand. Draw a grid with the browsers as rows and the operating systems as columns: its 9 cells are the 9 browser–OS pairs, one test each. Write a language in each cell so that every language appears once in every row and once in every column. Every row then holds all browser–language pairs, and every column all OS–language pairs.

Nine tests cover all 27 value pairs of browser, operating system and language: each cell is one test, and each language appears once in every row and every column.
BrowserOperating system
WindowsmacOSLinux
ChromeEnglish#1Arabic#2Hindi#3
FirefoxArabic#4Hindi#5English#6
EdgeHindi#7English#8Arabic#9
  • English
  • Arabic
  • Hindi
How to read the grid
Cell One test: the browser of its row, the operating system of its column and the language written in it. The 9 cells are the 9 browser–OS pairs.
Row All three languages appear once, so every browser–language pair is covered.
Column All three languages appear once, so every OS–language pair is covered.

Testing all combinations would take 27 tests. This layout, a Latin square, is one of several valid 9-test sets.

  • Each row is a configuration, not a test case: run the same checkout scenario, with its steps and expected results, in all nine.
  • The Pairwise Testing Generator may return 10 tests for this input; any set with 100% pair coverage is correct.
  • Chrome on Windows in Arabic is not in the set, although each of its pairs is. If analytics show that most customers use it, add it as a tenth test: pairwise testing treats all pairs as equally important, risk does not.
Text version
#  Browser  OS       Language
1  Chrome   Windows  English
2  Chrome   macOS    Arabic
3  Chrome   Linux    Hindi
4  Firefox  Windows  Arabic
5  Firefox  macOS    Hindi
6  Firefox  Linux    English
7  Edge     Windows  Hindi
8  Edge     macOS    English
9  Edge     Linux    Arabic

9 tests instead of 27 combinations; 27 of 27 value pairs covered

Try it: Pairwise Testing Generator

Where pairwise testing stops

Pairwise testing assumes that an interaction failure needs at most two particular values to appear. It guarantees every pair, not every triple: a failure that needs Chrome, Windows and Arabic together is found only if that triple happens to be in the set.

  • Interactions of three or more values can be missed. For high-risk features, use 3-wise testing, which covers every triple of values instead of every pair; the lesson on combinatorial testing shows how.
  • It does not choose the values: a partition or boundary missing from the value list is never tested, so select values with equivalence partitioning and boundary value analysis first.
  • It knows nothing about impossible or important combinations: impossible pairs need constraints, and key configurations must be added deliberately.
  • Invalid values do not belong in the combined set: a test with two invalid values usually stops at the first error and hides the second, which is called masking. Test each invalid value on its own.
  • It does not fit every problem: use a decision table when a business rule decides the outcome from specific combinations, and state transition testing when the order of events matters.

Common mistakes

  • Reporting "all combinations covered" when only all pairs are; say "27 of 27 value pairs in 9 tests".
  • Entering raw ranges as values, such as every age from 1 to 100, instead of partition representatives and the boundaries that matter.
  • Mixing invalid values into the pairwise model, so that one rejected input masks the others.
  • Deleting rows that turn out to be impossible without regenerating, which silently drops the other pairs those rows carried.
  • Adding a browser or a language without regenerating the set and rechecking coverage.
  • Leaving out the configuration most customers actually use because the generator did not happen to pick it.

The QA perspective

Use pairwise testing whenever the test basis lists options that combine: supported browsers and devices, languages, roles, plans, payment methods, feature flags. During test analysis and design, write the model (parameters, values, impossible combinations) and review it with the developers and the product owner: which values are really supported, which pairs cannot happen, and which configurations matter most according to analytics, support tickets and the User-Agent strings in server logs.

Keep the model as testware next to the test cases: parameters, constraints, the tool used, the generated set and the coverage achieved. You can then regenerate when something is added and report precisely what was and was not covered. When a configuration fails, change one value at a time to find the value or pair that triggers the failure, and name it in the bug report.

Practice exercise

Build a pairwise set for a subscription checkout

Your task

A subscription sign-up page combines the four parameters below, and every combination is allowed. Count the combinations and the value pairs, build a pairwise set by hand, and compare it with the Pairwise Testing Generator.

Then name one combination your set does not contain, and say when you would add it as an extra test.

Material
Plan:     Basic, Pro, Business
Payment:  card, wallet, bank transfer
Billing:  monthly, yearly
Currency: SAR, USD
Steps
  1. Count all combinations.
  2. Count the value pairs for each pair of parameters, then the total.
  3. Work out the minimum number of tests from the two largest parameters.
  4. Start with a Plan × Payment grid of nine cells, then fill in billing and currency so that every pair appears.
  5. Run the same parameters through the Pairwise Testing Generator and compare size and coverage.
Show the model answer
Model answer

Combinations: 3 × 3 × 2 × 2 = 36.

Value pairs: Plan–Payment 9, Plan–Billing 6, Plan–Currency 6, Payment–Billing 6, Payment–Currency 6, Billing–Currency 4; total 37. The minimum is 3 × 3 = 9 tests, one for each Plan–Payment pair.

One valid set: Basic · card · monthly · SAR, Basic · wallet · yearly · SAR, Basic · bank transfer · monthly · USD, Pro · card · yearly · USD, Pro · wallet · monthly · SAR, Pro · bank transfer · monthly · SAR, Business · card · monthly · SAR, Business · wallet · monthly · USD, Business · bank transfer · yearly · SAR. Every plan and every payment method appears with both billing periods and both currencies, and all four billing–currency pairs appear.

A generator may return 10 tests; any set with all 37 pairs is correct. Not in this set: Business paid by bank transfer in USD; add it if that path carries high risk, such as large invoices from business customers abroad.

Frequently asked questions

Is pairwise testing the same as using orthogonal arrays?

Not quite. An orthogonal array is one way to build a pairwise set in which every pair appears the same number of times; the 9-test example in this lesson is one. Pairwise testing only requires every pair at least once, which lets generators handle parameters with different numbers of values and impossible combinations.

How many tests does a pairwise set need?

At least the value count of the largest parameter times that of the second largest. Beyond that the size grows slowly: adding screen size to the lesson example raises the combinations from 27 to 81, yet 9 tests can still cover all 54 value pairs, and ten parameters with three values each (59,049 combinations, 405 value pairs) fit in fewer than 30 tests.

Can I use pairwise testing for form inputs, not only for configurations?

Yes, when several inputs are independent of each other and each has a few representative values, for example the filters of a search page. When a business rule decides the outcome from specific combinations of conditions, a decision table is the better technique.

References

Practise with Mutqan tools

Build decision tables from conditions and actions, generate all rule combinations and collapse impossible ones.

Test Design

Parse User-Agent strings into browser, version, engine, OS, device type and bot detection.

Web

Go deeper

Your progress on this topic

Part of the QA Roadmap