EveryRole

Boundary value testing, without the theory

Boundary value analysis on a real form: a field of 1 to 60 characters needs four test values, all at the edges. What to type, and what we found in our own app.

If a field has a limit, test the limit and one step past it. That is boundary value testing, all of it. The textbooks give it a chapter. You need four values.

Our practice app has a name field that must hold 1 to 60 characters. The values worth typing are 0, 1, 60 and 61.

A ruler for a name of 1 to 60 characters. The values 0 and 61 are refused, 1 and 60 are accepted. Everything from 2 to 59 behaves the same.
Four values at the edges. One value from the middle if you want to feel thorough.

Thirty characters will work. You know that because you typed a thirty-character name while building the form. Nobody has typed the sixtieth character, and the sixtieth character is where “less than 60” and “at most 60” stop meaning the same thing.

Why the edges

A limit is one comparison in the code: < or <=. Pick the wrong one and the app is off by one, at exactly one value. Everywhere else in the range the two behave the same, so no amount of testing in the middle will ever find it.

There is a second reason. A limit is usually written down in more than one place: the field in the page, the check on the server, the column in the database. Three places, typed by hand on three different days. They agree in the middle of the range. They disagree at the edge.

What happened when we tried it on our own app

We ran the four values on the practice app while writing this post, expecting nothing.

61 characters, typed. The field has maxlength="60", so the browser stopped at 60. No message, the extra character just didn’t appear.

The new item form with a long name typed. The text stops after "support team" and the cursor sits at the 60-character limit.
We typed 61 characters. The field holds 60 and says nothing about the one it dropped.

Then we pressed “Create” and read the item’s page. The name on it was 59 characters long.

It took a minute to see why. Our 61-character test name happened to have a space at position 60. The browser cut it to 60 characters, ending in that space. The server trimmed the space. Typed 61, saved 59, and at no point did anything tell the person their name had been changed twice.

Is that a bug? For an item name, probably not one anyone would report. For a bio, a product title or a street address cut mid-word, it is. Either way, we would not have known without typing past the limit and reading what was saved.

61 characters, past the browser. A maxlength attribute only limits typing in that page. So we removed it in the developer tools and sent 61 characters for real.

The practice app refusing a 61-character name sent past the browser's limit, with the message "A name of 1 to 60 characters, please"
61 characters sent past the browser. The server has its own check, and it agrees: 60 is the most.

The server refused, with the right range in the message, so both guards agree on 60. You only get to say that after looking. The page it answers with is another matter: no form, nothing kept. That is the dead end from the empty-form post, and a limit test finds it too.

Boundary value test cases for one field

ValueType thisWhat must come out
NothingLeave it emptyRefused. The message names the field.
The least1 characterAccepted. Saved as typed.
The mostExactly 60 charactersAccepted. All 60 are on the saved page.
One past61 charactersRefused, or stopped with a visible sign. Never saved cut short without a word.

For “the most”, count what was saved, so you have an expected result two people would agree on. Don’t glance at it. A name that lost its last character looks fine at a glance.

Keep a string of the right length somewhere you can paste from. Ours is a plain sentence. A row of sixty “a” characters works too, but a sentence shows you where it was cut.

Limits that don’t look like limits

Text length is the obvious one. The same four-value idea applies anywhere there is a least and a most:

  • Numbers. A quantity from 1 to 99: try 0, 1, 99, 100. And try 1.5, which is between two valid values and slips through any check that only compares.
  • Dates. A booking no more than 90 days ahead: day 90 and day 91. A birth date: today, and tomorrow.
  • Counts. A plan that allows five projects: create the fifth, then try the sixth. A team of at most ten: invite the eleventh.
  • Files. An upload limit of 10 MB: a file just under, and one just over.
  • Lists. A page that shows 20 rows: what does it do with 20, and with 21? Is there a second page, and is row 21 on it?
  • Time. A link that works for one hour. A session that ends after thirty minutes without activity.

The count limits are the ones that involve money, so they deserve a real test. Our practice app can put an editor on a limit of items: at the limit, the “New item” page says so and its button is disabled, and a request sent anyway is refused. That is three behaviours to check for one limit: the message before, the disabled control, and the refusal behind it.

What to skip

You don’t need every value in the range. The textbooks call that equivalence partitioning: values that the code treats the same way form one group, and one value from each group is enough. Nor do you need random values, or the famous list of strange strings on every field. If the four edge values behave, the comparison is right. Spend the time you saved on the next field.

One value we do add for text fields is a very long paste, a few thousand characters, sent past the browser. It isn’t a boundary. It answers a different question: does the server have any limit at all, or does it try to store whatever arrives?

How EveryRole handles limits

When EveryRole explores a form it records what the page declares about each field: required, the most characters, a number’s least and most. From that, code decides which cases apply. A field that states a maximum gets a “Too long” case, which types one character more than the maximum. It types into the page like a person, so on a field with maxlength the browser drops the extra character, and the case shows you what was saved. Sending past the browser to test the server’s own check is still a test for you. A number field gets a case for 0, a negative number and the largest value.

Both are extra cases. The main cases at a form (good input, empty, wrong format, wrong then right) run every time. The extra ones are off until you turn them on for the forms where a limit matters.

It can’t know a limit the page never states. If your server allows 60 characters and the page doesn’t say so, no case is made for it, and you will find out the way your users do. So state your limits in the page. People need to see them anyway.

Keep reading

Test cases

Happy path vs edge cases: where the bugs are

The happy path is the one route through a feature where everything goes right. Test it first, then test five edge cases per step. Which five, and why those.

5 min read