Testing note · Software quality

Bugs live
at the edge

Four tests. One hidden mistake. Where would you look?

What is a test, in plain words?

A form should accept an age only from 18 to 65. That rule is the spec. Someone wrote the code, and it has one small mistake. A test means: give it one age, then compare its answer with the spec. Testers rarely get to try everything, so the skill is choosing a few inputs that would catch the mistake.

1. You pick an ageFor example 30, or 18, or 66.
→
2. The program answersAccept or reject. It has one hidden mistake.
→
3. You compare with the specA mismatch is a bug found.

The classic mistake: off by one

Count the posts of a fence that has some number of sections. Slide it and watch: the posts are always one more than the sections. Code that counts sections when it should count posts is off by one. It is the most common bug at an edge.

Now find one

The spec is below. The program has one secret off-by-one mistake, at either the lower or the upper edge.

Spec: accept ages from 18 to 65, both included.

1Type an age and press Add test. You may add up to four. 2Press Run. 3Read the table.

program matches the specmismatch: a bug found
Add tests, then run. Try “Middle picks” first, and then “Edge picks”.

So why edges?

The program treats all ages below 18 the same way, so one example from that group says as much as a hundred. The same holds for the middle and for the top. The mistakes hide where the groups meet, so a good set of tests is one value from each group, plus the values on each side of every border.

Below 18All treated the same, so one example is enough. The edge is 17.
18 to 65Also one group. Its edges are 18 and 65.
Above 65One more group. The edge is 66.

Edges in the other pages

Login limitsIf a site allows 5 tries, test the 5th and the 6th. The quiet defense page is about rules like this.
Break-evenIn how many tickets the decision flips at 90%. At exactly 90% the answer is a tie, which is where a coder is most likely to write > instead of ≥.
When script is missing“What if JavaScript never loads?” is an edge too. Plain layer first tests it by building that case first.
← TopicsQuiz