Orthogonal Array Testing is a statistical method used to identify a subset of test cases that can be used to test all possible combinations of input parameters with fewer test cases than exhaustively testing all possible combinations. An Orthogonal Array is a mathematical matrix that specifies a set of test cases that will test all possible combinations of input parameters, while minimizing the number of test cases required.
In Orthogonal Array Testing, the input parameters are varied systematically, and the test cases are designed to cover all possible combinations of input parameter values with minimal redundancy. The goal is to achieve maximum code coverage with minimum testing effort.
Orthogonal Array Testing is particularly useful when testing software applications with multiple input parameters, each of which can take on multiple values. By using Orthogonal Array Testing, testers can reduce the number of test cases required to achieve maximum coverage, while still ensuring that all possible combinations of input parameter values are tested.
An orthogonal array is a mathematical structure that can be represented by the following formula:
Where:
- N is the number of test cases required to cover all possible combinations of input parameters. or Actual number of test cases required to test all possible combinations of input parameters.
- k is the number of input parameters being tested.
- s is the strength of the test, which is the minimum number of input parameters that must be tested simultaneously to ensure that all possible combinations of input parameters are tested.
- v is the number of possible values for each input parameter.
To Find minimum number of test cases required to achieve maximum code coverage-
Where:
- The value of N represents the minimum number of test cases required to achieve maximum code coverage by testing all possible combinations of input parameters without redundancy.
By using the orthogonal array formula, it is possible to design a set of test cases that efficiently explore the input space of a software application and help achieve maximum code coverage with minimum test cases.
it's important to note that OAT does not necessarily provide the absolute minimum number of test cases needed to achieve maximum coverage. It's simply a technique that can help reduce the number of test cases needed while still achieving a high level of coverage.
Apply the above formula in following example-
Example- Pizza ordering system that requires three input parameters:
- Size, the size can be small, medium, or large.
- Crust type, the crust type can be thin or thick.
- Toppings, the toppings can be cheese, pepperoni, sausage, mushroom, and onion.
Without using OAT: We would need to test all possible combinations of size, crust type, and toppings, which would require 3 x 2 x 5 = 30 test cases.
Using OAT: However, by using OAT, we can reduce the number of test cases required while still covering all possible combinations of input parameters.
Assuming we use an orthogonal array of strength 2, we can determine the minimum number of test cases required to cover all possible combinations of size, crust type, and toppings as follows:
- k = 3 (there are three input parameters being tested: size, crust type, and toppings)
- s = 2 (to ensure that all possible combinations of size, crust type, and toppings are tested, we need to test two input parameters simultaneously)
- v = 3, 2, 5 (there are
three
possible values forsize
,two
possible values forcrust type
, andfive
possible values fortoppings
)
Using the orthogonal array formula, we can calculate the minimum number of test cases required to cover all possible combinations of size, crust type, and toppings as follows:
There are three input parameters being tested: A, B, and C (size, crust type, and toppings).
- Parameter
A
has three possible values - Parameter
B
has two possible values - Parameter
C
has five possible values.
So, v = 3 (for A), v = 2 (for B), and v = 5 (for C).
Therefore,
The exponent of 1 for each value is used because each input parameter(size, crust type, and toppings) is being tested only once in this example.
So Now minimum test cases as following-
- Therefore, we only need to run 15 test cases to cover all possible combinations of size, crust type, and toppings:
- small-thin-cheese, small-thick-pepperoni, small-thin-sausage, small-thick-mushroom, medium-thin-onion, medium-thick-cheese, medium-thin-pepperoni, medium-thick-sausage, large-thin-mushroom, large-thick-onion, small-thick-cheese, small-thin-pepperoni, small-thick-sausage, small-thin-mushroom, and medium-thick-onion.
Represented in the table form as following-
Test Case | Size | Thickness | Topping |
---|---|---|---|
1 | Small | Thin | Cheese |
2 | Small | Thick | Pepperoni |
3 | Small | Thin | Sausage |
4 | Small | Thick | Mushroom |
5 | Medium | Thin | Onion |
6 | Medium | Thick | Cheese |
7 | Medium | Thin | Pepperoni |
8 | Medium | Thick | Sausage |
9 | Large | Thin | Mushroom |
10 | Large | Thick | Onion |
11 | Small | Thick | Cheese |
12 | Small | Thin | Pepperoni |
13 | Small | Thick | Sausage |
14 | Small | Thin | Mushroom |
15 | Medium | Thick | Onion |
How the OAT algorithm can be applied to generate test cases?
The OAT algorithm is a statistical approach that is used to design a set of test cases that can efficiently explore the input space of a software application and help achieve maximum code coverage with minimum test cases. Here are the general steps to apply the OAT algorithm to generate test cases-
-
Define the input parameters: Identify the input parameters of the software application that need to be tested. For example, in the case of a login form, the input parameters might include username, password, and login button.
-
Determine the possible values of each parameter: Identify the possible values of each input parameter. For example, the possible values of the username parameter might include valid username, invalid username, and blank username.
-
Determine the strength of the test: Determine the strength of the test based on the number of parameters and their possible values. For example, a test with two parameters, each with two possible values, would have a strength of two. A test with three parameters, each with three possible values, would have a strength of three.
-
Select an orthogonal array: Select an orthogonal array that has the appropriate strength to test all possible combinations of input parameters. An orthogonal array is a mathematical structure that ensures that each input parameter is tested at least once and that all possible combinations of input parameters are tested without redundancy.
-
Assign input values to test cases: Assign input values to each test case based on the selected orthogonal array. Each test case will have a unique combination of input values that corresponds to a row in the orthogonal array.
-
Execute test cases: Execute the test cases and evaluate the results to ensure that the software application is working as expected.
By following these steps, the OAT algorithm can be applied to generate a set of test cases that efficiently explore the input space of a software application and help achieve maximum code coverage with minimum test cases.
Orthogonal Array Testing Advantages and Disadvantages:
Advantages:
- Saves time and resources: By using orthogonal arrays, a smaller number of test cases can cover all possible combinations of input parameters, which can save time and resources during testing.
- Ensures coverage: Orthogonal testing ensures that all possible combinations of input parameters are tested, which helps to ensure complete test coverage.
- Identifies defects early: By testing a wide range of input parameter combinations, orthogonal testing can help identify defects early in the development cycle.
Disadvantages:
- Limited to a specific number of input parameters: Orthogonal testing is limited to a specific number of input parameters, which means that it may not be suitable for testing complex systems with many input parameters.
- Requires domain knowledge: To effectively use orthogonal testing, testers need to have a good understanding of the domain and the possible input parameter values, which may require additional training.
- Can miss interactions: While orthogonal testing ensures that all possible combinations of input parameters are tested, it does not test for interactions between input parameters, which may lead to defects being missed.