All Pair Technique

"All Pairs" is a test design technique that can be used when there are several variables to test. The test cases include all the pairs of values for every variable. The output of "All Pairs" technique is that every value is paired with another value at least once.

Here are some examples of testing several variables:

-    A search screen with several search criteria

-    Configuration options of software. 
-    Configuration options of hardware. 
-    Compatibility testing across different OS and browser combinations.

"All Pairs" drastically reduces the number of test cases required to test software and it can help you find most errors with the smallest number of test cases.

Example:

Let say, for example, there are 3 parameters that can be given for a search criteria: P1, P2 and P3.

-    P1 can have the values as '10' and '50'.

-    P2 can have the values as 'g' and 'c'.

-    P3 can have the values as 'a' and 'b'.

Step 1 - calculate all combinations

The Cartesian product will be:

P1 X P2 X P3 = {10, 50} X {g, c} X {a, b}

In tabular format:


Test Case # Values Participates       Result      
1 {10, 50}X{g, c}X{a, b} (10, g, a)
2 {10, 50}X{g, c}X{a, b} (10, g, b)
3 {10, 50}X{g, c}X{a, b} (10, c, a)
4 {10, 50}X{g, c}X{a, b} (10, c, b)
5 {10, 50}X{g, c}X{a, b} (50, g, a)
6 {10, 50}X{g, c}X{a, b} (50, g, b)
7 {10, 50}X{g, c}X{a, b} (50, c, a)
8 {10, 50}X{g, c}X{a, b} (50, c, b)


Step 2 – base table

Now, let's create a table that each column represents a variable and each row represents a test case combination:

Test Case # P1 P2 P3
1 10 g a
2 10 g b
3 10 c a
4 10 c b
5 50 g a
6 50 g b
7 50 c a
8 50 c b


Step 3 - pick the last row (mark in red):

Test Case # P1 P2 P3
1 10 g a
2 10 g b
3 10 c a
4 10 c b
5 50 g a
6 50 g b
7 50 c a
8 50 c b


Step 4 – If all pairs exist in other rows – delete the last row and go up, if not keep the row and go up to the next row:

Test Case # P1 P2 P3
1 10 g a
2 10 g b
3 10 c a
4 10 c b
5 50 g a
6 50 g b
7 50 c a
8 50 c b
We can see that the pair (50, c) exists in test case 7, the pair (50, b) exists in test case 6 and the pair (t, b) exists in test case 4. Because all pairs in test case 8 (the last row) exists in above rows, we can delete test case 8.

The new table will be:

Test Case # P1 P2 P3
1 10 g a
2 10 g b
3 10 c a
4 10 c b
5 50 g a
6 50 g b
7 50 c a


Now, let's move one row up to test case 7:
Test Case # P1 P2 P3
1 10 g a
2 10 g b
3 10 c a
4 10 c b
5 50 g a
6 50 g b
7 50 c a



We don’t have the couple (50, b) so we keep the line (test case 6) and move up to the next row up to test case 5.



Test Case # P1 P2 P3
1 10 g a
2 10 g b
3 10 c a
4 10 c b
5 50 g a
6 50 g b
7 50 c a



We can see that the pair (50, g) exists in test case 6, the pair (50, a) exists in test case 7 and the pair
(g, a) exists in test case 1. Because all pairs in test case 5 (the current row) exists in other rows, we can delete test case 5.



The new table will be:


Test Case # P1 P2 P3
1 10 g a
2 10 g b
3 10 c a
4 10 c b
6 50 g b
7 50 c a


Now, let's move one row up to test case 4.
Test Case # P1 P2 P3
1 10 g a
2 10 g b
3 10 c a
4 10 c b
6 50 g b
7 50 c a


We don’t have the couple (c, b) so we keep the line (test case 4) and move up to the next row up to test case 3:
Test Case # P1 P2 P3
1 10 g a
2 10 g b
3 10 c a
4 10 c b
6 50 g b
7 50 c a


We can see that the pair (10, a) exists in test case 1, the pair (10, c) exists in test case 4 and the pair (c, a) exists in test case 7. Because all pairs in test case 3 (the current row) exists in other rows, we can delete test case 3.


The new table will be:

Test Case # P1 P2 P3
1 10 g a
2 10 g b
4 10 c b
6 50 g b
7 50 c a


Now, let's move one row up to test case 2:


Test Case # P1 P2 P3
1 10 g a
2 10 g b
4 10 c b
6 50 g b
7 50 c a


We can see that the pair (10, g) exists in test case 1, the pair (10, b) exists in test case 4 and the pair (g, b) exists in test case 6. Because all pairs in test case 2 (the current row) exists in other rows, we can delete test case 2.

The new table will be:

Test Case # P1 P2 P3
1 10 g a
4 10 c b
6 50 g b
7 50 c a


Now, let's move one row up to test case 1.


Test Case # P1 P2 P3
1 10 g a
4 10 c b
6 50 g b
7 50 c a


We don’t have the couples (10, g), (10, b), (g, b) so we keep the line.


Test Case # P1 P2 P3
1 10 g a
4 10 c b
6 50 g b
7 50 c a


Now, no more lines left which means that after using "All Pairs" technique, we have 4 test cases to test. We reduced the number of test cases from 8 to 4 (50% less).