The Test Management Guide Software Test Guide RSS Feed
*
Accessibility

Background

BS7925-2 Annex B - Guidelines for Testing and Test Measurement

Boundary Value Analysis



Annex B   
(informative)

Guidelines for Testing Techniques and Test Measurement

B.2    Boundary Value Analysis

Introduction

Boundary Value Analysis is based on the following premise.  Firstly, that the inputs and outputs of a component can be partitioned into classes that, according to the component's specification, will be treated similarly by the component and, secondly, that developers are prone to making errors in their treatment of the boundaries of these classes.  Thus test cases are generated to exercise these boundaries.

Example

Consider a component, generate_grading, with the following specification:

The component is passed an exam mark (out of 75) and a coursework (c/w) mark (out of 25), from which it generates a grade for the course in the range 'A' to 'D'.  The grade is calculated from the overall mark which is calculated as the sum of the exam and c/w marks, as follows:

   greater than or equal to 70                            -     'A'

   greater than or equal to 50, but less than 70   -     'B'

   greater than or equal to 30, but less than 50   -     'C'

   less than 30                                                -     'D'

 

Where a mark is outside its expected range then a fault message ('FM') is generated.  All inputs are passed as integers.

Initially the equivalence partitions are identified, then the boundaries of these partitions are identified, and then test cases are derived to exercise the boundaries.  Equivalence partitions are identified from both the inputs and outputs of the component and both valid and invalid inputs and outputs are considered.

0 ≤ exam mark ≤ 75

0 ≤ coursework mark ≤ 25

 

The most obvious invalid partitions can be described by:

exam mark > 75

exam mark < 0

coursework mark > 25

coursework mark < 0

 

Partitioned ranges of values can be represented pictorially, therefore, for the input, exam mark, the same notation leads to:


And for the input, coursework mark, we get:


For each boundary three values are used, one on the boundary itself and one either side of it, the smallest significant distance away, as shown below:


Thus the six test cases derived from the input exam mark are:

Test Case

1

2

3

4

5

6

Input (exam mark)

-1

0

1

74

75

76

Input (c/w mark)

15

15

15

15

15

15

Boundary tested (exam mark)

0

75

Exp. Output

'FM'

'D'

'D'

'A'

'A'

'FM'


Note that the input coursework (c/w) mark has been set to an arbitrary valid value of 15.

The test cases derived from the input coursework mark are thus:

Test Case

7

8

9

10

11

12

Input (exam mark)

40

40

40

40

40

40

Input (c/w mark)

-1

0

1

24

25

26

Boundary tested (c/w mark)

0

25

Exp. Output

'FM'

'C'

'C'

'B'

'B'

'FM'


Note that the input exam mark has been set to an arbitrary valid value of 40.

Less obvious invalid input equivalence partitions would include any other inputs that can occur not so far included in a partition, for instance, non-integer inputs or perhaps non-numeric inputs.  In order to be considered an equivalence partition those values within it must be expected, from the specification, to be treated in an equivalent manner by the component.  Thus we could generate the following invalid input equivalence partitions:

exam mark = real number

exam mark = alphabetic

coursework mark = real number

coursework mark = alphabetic

etc.

 

Although these are valid equivalence partitions they have no identifiable boundaries and so no test cases are derived.

Next, the partitions and boundaries for the outputs are identified.  The valid partitions are produced by considering each of the valid outputs for the component thus:

'A'                        is induced by     70 ≤ total mark ≤ 100

'B'                        is induced by     50 ≤ total mark < 70

'C'                        is induced by     30 ≤ total mark < 50

'D'                        is induced by     0 ≤ total mark < 30

'Fault Message'     is induced by     total mark > 100

'Fault Message'     is induced by     total mark < 0

 

where total mark = exam mark + coursework mark.

'Fault Message' is considered here as it is a specified output.  The equivalence partitions and boundaries for total mark are shown below:

Thus the test cases derived from the valid outputs are:

Test Case

13

14

15

16

17

18

19

20

21

Input (exam mark)

-1

0

0

29

15

6

24

50

26

Input (c/w mark)

0

0

1

0

15

25

25

0

25

total mark (as calculated)

-1

0

1

29

30

31

49

50

51

Boundary tested (total mark)

0

30

50

Exp. Output

'FM'

'D'

'D'

'D'

'C'

'C'

'C'

'B'

'B'

 

Test Case

22

23

24

25

26

27

Input (exam mark)

49

45

71

74

75

75

Input (c/w mark)

20

25

0

25

25

26

total mark (as calculated)

69

70

71

99

100

101

Boundary tested (total mark)

70

100

Exp. Output

'B'

'A'

'A'

'A'

'A'

'FM'


The input values of exam mark and coursework mark have been derived from the total mark, which is their sum.

An invalid output would be any output from the component other than one of the five specified.  It is difficult to identify unspecified outputs, but obviously they must be considered as if we can cause one then we have identified a flaw with either the component, its specification, or both.  For this example three unspecified outputs were identified ('E', 'A+', and 'null'), but it is not possible to group these possible outputs into ordered partitions from which boundaries can be identified and so no test cases are derived.

So far several partitions have been identified that appear to be bounded on one side only.  These are:

exam mark > 75

exam mark < 0

coursework mark > 25

coursework mark < 0

total mark > 100

total mark < 0

 

In fact these partitions are bounded on their other side by implementation-dependent maximum and minimum values.  For integers held in sixteen bits these would be 32767 and -32768 respectively. 

Thus, the above partitions can be more fully described by:

75 < exam mark ≤ 32767

-32768 ≤ exam mark < 0

25 < coursework mark ≤ 32767

-32768 ≤ coursework mark < 0

100 < total mark ≤ 32767

-32768 ≤ total mark < 0

 

It can be seen that by bounding these partitions on both sides a number of additional boundaries are identified, which must be tested.  This leads to the following additional test cases:

Test Case

28

29

30

31

32

33

Input (exam mark)

32766

32767

32768

-32769

-32768

-32767

Input (c/w mark)

15

15

15

15

15

15

Boundary tested (exam mark)

32767

-32768

Exp. Output

'FM'

'FM'

'FM'

'FM'

'FM'

'FM'

 

Test Case

34

35

36

37

38

39

Input (exam mark)

40

40

40

40

40

40

Input (c/w mark)

32766

32767

32768

-32769

-32768

-32767

Boundary tested (c/w mark)

32767

-32768

Exp. Output

'FM'

'FM'

'FM'

'FM'

'FM'

'FM'

 

Test Case

40

41

42

43

44

45

Input (exam mark)

16383

32767

1

0

-16384

-32768

Input (c/w mark)

16383

0

32767

-32767

-16384

-1

total mark (as calculated)

32766

32767

32768

-32767

-32768

-32769

Boundary tested (total mark)

32767

-32768

Exp. Output

'FM'

'FM'

'FM'

'FM'

'FM'

'FM'

 

It should be noted that where invalid input values are used (as above, in test cases 1, 6, 7, 12, 13, and 27-45) it may, depending on the implementation, be impossible to actually execute the test case.  For instance, in Ada, if the input variable is declared as a positive integer then it will not be possible to assign a negative value to it.  Despite this, it is still worthwhile considering all the test cases for completeness.

The above test case suite achieves 100% boundary value coverage as it ensures that all identified boundaries are exercised by at least one test case.  Lower levels of coverage would be achieved if all the boundaries identified are not all exercised.  If all the boundaries are not identified, then any coverage measure based on this incomplete set of boundaries would be misleading.

© RuleWorks - All Rights Reserved - Policy - - Sitemap