Wednesday, July 15, 2009

Explain Boundary Value Analysis.

Boundary Value Analysis

It has been noticed that programs often fail on some special values that lie on the boundary of an equivalence class or we can say that most functional errors from input and output data occur on or around these boundaries. Boundary Value Analysis requires that the tester selects values close to edges so that both the upper and lower edges of an equivalence class are covered by test cases.

Boundary value analysis is different from equivalence partitioning:

We select “any value” from an equivalence class as being representative but in BVA one or more values should be selected in such a way that each edge of the equivalence class is the subject of a test.

Instead of focusing attention on the input conditions (input space), In BVA test cases are also developed by taking into account the result space (output equivalence classes).

For boundary-value analysis, there are some guidelines e.g.

In case of ranges, select the boundary elements of the range and an invalid value just beyond the two ends (for the two invalid equivalence classes). For Example if the range is 0.0 <= x <= 1.0, then the test cases are 0.0, 1.0 (valid inputs), and −0.1, and 1.1 (for invalid inputs). If the input is a list, attention should be focused on the first and last elements of the list. For rest of the guidelines see The art of software testing By Glenford J. Myers, Tom Badgett, Todd M. Thomas, Corey Sandler

A simple way to form test cases in BVA: Suppose each input variable has a defined range. Then there are six boundary values—the extreme ends of the range, just beyond the ends, and just before the ends. If an integer range is min to max, then the six values are min−1, min, min+1, max−1, max, max+1.

For example if you have a field that accepts integers between 0 and 10 these would be the tests.

min-1 = -1
min = 0
min+1 = 1
nominal = any number between 2 and 8
max-1 = 9
max = 10
max+1 = 11

Examples of Boundary Value Analysis

2. Practical software testing By Ilene Burnstein

Examples (from Software Testing and Continuous Quality Improvement by William E. Lewis):

Field Ranges - for example Input can range from integers 0 to 100,
Test cases include –1, 0, 100, and 101

For example Input can range from real numbers 0 to 100.0,
Test cases include –.00001, 0.0, 100.0, 100.00001

For Tables or Arrays we can focus on the first and last rows, for example, read, update, write, delete.

1. Vertically and horizontally scroll to the end of scroll bars
2. Upper and lower limits of color selection
3. Upper and lower limits of sound selection
4. Boundary gizmos, for example, bounds available sets of available input values
5. Spinners, for example, small edit field with two half-height buttons

Advantages of Boundary Value Analysis

The mechanical nature of the procedure and the symmetry of the tests identified make the BVA procedure easy to remember and use, especially given that critical input boundaries are often already explicitly identified in the requirements. With BVA, one can adjust the number of test cases identified and, thus, the resources expended on testing effort, depending upon the robustness demands of the product. (Source)

BVA works well when the program to be tested is a function of several independent variables that represent bounded physical quantities. (Source)

Boundary Value Analysis is good at revealing possible user interface/user input problems.

Disadvantages / Limitations of Boundary Value Analysis

Boundary Value Analysis does not make sense for Boolean variables. (Source)

Obviously when variables are dependent.

Boundary Value Analysis - Multiple Choice Questions

Also see:

1. A Concise Introduction to Software Engineering by Pankaj Jalote
2. Cem Kaner Video on BVA
6. Another Interesting Video on Boundary Testing (James Bach & Michael Kelly)
7. stpmag

February 2007 (Finite Boundaries)
April 2007 (In Search of Boundaries)


Related Post:
Equivalence Partitioning