QA Interview Hub · Knowledge base · Quizzes · Українська

QA Fundamentals › Test design techniques

What is boundary value analysis?

Boundary value analysis tests the edge of a range and the values next to it, because errors such as < instead of <= show only there. The 2-value approach takes a boundary and the closest value on the other side, and 3-value adds the neighbour inside: for 1 to 10,000 that is 0, 1, 2, 9,999, 10,000, 10,001. The step depends on the type, and inclusive boundaries are clarified in requirements.

QA Fundamentals · Test design techniques

A "1 to 10,000" field accepts 10,001 and rejects 10,000. Which test would catch it?

A tester checked the amount field with 500, 5,000 and 9,000: all green. In production a customer cannot transfer exactly 10,000, because the developer wrote amount < 10000 instead of <=. Equivalence classes would not have found it: 5,000 and 10,000 lie in one class. That is what boundary value analysis (BVA) is for.

How it works and why

Bugs live where a condition changes the outcome. A comparison operator gives the same result for all values except those right next to the boundary. This is where developers confuse < and <=, count from zero or from one, round the wrong way. So we test the boundary itself and the values next to it.

There are two approaches, and this site follows one convention. 2-value BVA: for each boundary take the value on the boundary and the nearest value on the other side, four values for a range. 3-value BVA: for each boundary take the value below, on and above it, that is six values per range (two boundaries by three).

Six values for the range 1–10,000

lower boundaryupper boundary 0No 1Yes 2Yes 9,999Yes 10,000Yes 10,001No
Figure 1. Three values at each boundary: below, on, above. The line shows where the outcome changes.

Example: which value catches which bug

The requirement: an amount from 1 to 10,000 inclusive. The developer wrote a condition with two off-by-one errors:

// requirement: 1 <= amount <= 10000
if (amount > 1 && amount < 10000) accept();
else reject();

Let us see how this code reacts to the values of the 3-value set and compare with the expected result:

ValueExpectedCodeMatch
0rejectrejectyes
1acceptrejectno, bug
2acceptacceptyes
9,999acceptacceptyes
10,000acceptrejectno, bug
10,001rejectrejectyes

The values 500, 5,000, 9,000 would pass without a single failure. Only two of the six find these bugs. 0 and 10,001 are needed for the opposite mistakes: amount >= 0 would accept 0, and amount <= 10001 would accept 10,001. The inner neighbours 2 and 9,999 come from 3-value BVA: by ISTQB they catch, for example, a limit check written as amount == 10000 instead of amount <= 10000, which the 2-value set misses.

2-value or 3-value

2-value: 4 values

0, 1, 10,000, 10,001. The boundary and the nearest value outside the range. Faster, catches typical operator mistakes.

3-value: 6 values

0, 1, 2, 9,999, 10,000, 10,001. Adds the neighbours inside. Wider, for when the boundary is shifted or the behaviour next to it is risky too.

Figure 2. Both approaches are legitimate, the choice depends on risk and time. On this site 3-value counts six values per range.

Money, lengths, dates

The step between neighbouring values depends on the type. For integers it is 1, for money 0.01, so the boundaries are 0.99, 1.00, 1.01 and 9,999.99, 10,000.00, 10,000.01. Separately, ask how the system rounds 10,000.004: the requirements must say whether it is 10,000.00 (accept) or a rejection.

Boundaries exist outside numeric fields too: a password length of 8–64 characters, a file size of 5 MB, the end of a month and 29 February, the time 23:59:59, a pagination page size, a daily limit. For a file size, clarify what "5 MB" means: 5,000,000 or 5,242,880 bytes. These differ, and the boundary sits elsewhere.

Limits and alternatives

  • The technique works for ordered values: numbers, dates, lengths, counts. A list of options (countries, account types) has no boundary, and equivalence classes apply there.
  • Whether the boundaries are inclusive (≤ or <) must be stated in the requirements. If it is not, that is a question to the analyst, not a guess.
  • BVA complements classes and does not replace them: classes give a representative from the middle of the range, BVA gives the values on the edges.

Typical mistakes

  • Testing only the lower boundary. The upper one carries the same risks.
  • Taking the boundary from a hint in the interface. The hint may differ from the requirements and the code.
  • Not checking values outside the range. It is 0 and 10,001 that show the rejection works.
  • Computing boundaries for decimals as for integers. The neighbour is then not 10,001 but 10,000.01.

Check yourself

A password must have 8 to 64 characters. Which length values for 2-value BVA?

Answer

7, 8, 64 and 65: the boundaries 8 and 64 and the nearest values outside the range. For 3-value, 9 and 63 are added, six values in total.

Why would the value 5,000 not find the error amount < 10000?

Answer

Because 5,000 is far from the boundary, and both operators, < and <=, give the same result for it. They differ only at the boundary itself, which is 10,000.

A price is accepted from 0.01 to 999.99. Which six values for 3-value?

Answer

0.00, 0.01, 0.02 and 999.98, 999.99, 1000.00. The step for money is 0.01, so neighbouring values differ by one cent.

In an interview. Junior: Errors most often sit at boundaries, so I test the boundary itself and the values next to it. For a range of one to ten thousand, in the three-value approach that is 0, 1, 2 and 9,999, 10,000, 10,001. For money I add cents. Middle/Senior: I clarify whether the boundaries are inclusive, pick 2-value or 3-value by risk, and for decimals I compute the step of the type. Separately I look for non-obvious boundaries: lengths, file sizes, dates, limits. I do boundaries and classes together, because classes give the middle of the range and BVA the edges.

More articles in this chapter