Pairwise Testing

HARSHVARDHAN SINGH CHAUHAN
4 min readNov 11, 2021

--

Pairwise testing is also known as All-pairs testing uses combinatorial method to arrive at the test data. It is a black-box test design technique in which test cases are designed to execute all possible discrete combinations of each pair of input parameters. A subset of the combination of all possible factors is generated to ensure the coverage.

Let us try to understand with an example of an eCommerce website where we are trying to look for a product after applying different filter criteria. For the ease of understanding, let us consider 3 filters having 2 possible values each.

Filter 1 → (A, B)

Filter 2 → (G, H)

Filter 3 → (Y, N)

This will generate total 2³ combinations. This may not look a very huge number at first but with the combinations and filters increasing, this will become a very big number.

Now, let us try to derive all the possible combinations which would required to be tested:

From here onwards the process of selection and rejection starts.

Consider test case # 1:

Here there are two pairs (A,G) and (G,Y). These two pairs are also present in test case # 2 and test case # 5. Since both the combinations are achieved in test case # 2 and test case # 5 respectively, hence we can remove test case # 1.

Similarly, consider test case # 3 since test case #2 is already taken in scope.

Here there are two pairs (A,H) and (H,Y). These two pairs are also present in test case # 4 and test case # 7. Since both the combinations are achieved in test case # 4 and test case # 7 respectively, hence we can remove test case # 3.

After the above process the table will look something like this where the blue rows are redundant and can be removed from scope and the rows with red pairs can be considered.

Now, if we look at the table, we have two test cases pending which are test case # 6 and test case # 8.

Let’s take them one by one.

Consider test case # 6:

Here there are two pairs (B,G) and (G,N). These two pairs are also present in test case # 5 and test case # 2. Since both the combinations are achieved in test case # 5 and test case # 2 respectively, hence we can remove test case # 6.

Similarly consider test case # 8:

Here there are two pairs (B,H) and (H,N). These two pairs are also present in test case # 7 and test case # 4. Since both the combinations are achieved in test case # 7 and test case # 4 respectively, hence we can remove test case # 8.

After the above process the table will look something like this where the blue rows are redundant and can be removed from scope and the rows with red pairs can be considered.

Now, let us combine both the tables and see which test case is in scope and which is out of scope out of all the combinations.

This is evident that out of 8 combinations of test cases, we have filtered out 4 and selected 4 test cases.

Now the question here is if we have bigger number of combinations, then do we derive all the combinations and then filter out. Certainly no, in that case we

  1. Order the values such that one with most number of values is the first and least is placed as the last variable.
  2. We start filling the table column by column.
  3. We start making the combinations of first two columns and then cascade till the last column in the same fashion.

The magic of pairwise testing is that it can reduce the number of test cases tremendously. If we have 4 fields with 3,2,2,2 values, then,

  1. Conventional testing technique results in 24 cases.
  2. Pairwise testing technique results in 6 cases.

Real time examples of pairwise testing:

  1. Any filter on website
  2. Cross browser testing with multiple combinations of OS, browser versions and devices.
  3. Calendar field.

Thanks for reading. Cheers!!

--

--

HARSHVARDHAN SINGH CHAUHAN
HARSHVARDHAN SINGH CHAUHAN

Written by HARSHVARDHAN SINGH CHAUHAN

An avid reader, spoken word artist, dog lover, explorer, full stack qa engineer...

No responses yet