EveryRole

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.

The happy path is the route through a feature where the user does everything right and the app does too. Edge cases are everything else: the empty field, the wrong password, the button pressed twice. The happy path is where you check that the feature exists. The edge cases are where you find the bugs.

You need both. The order matters, and so does knowing when to stop.

The happy path is what you already tested

Here is the happy path of our practice app: an editor creates an item.

No surprises. This is the route the feature was built along.

It works. Of course it works: this is the exact sequence the person who built it went through again and again while building it. It’s also what gets shown in the demo, and what the first automated test covers, because it is the easiest test to write.

So after all that effort, one route through the feature has been checked many times and every other route has been checked zero times.

The same three steps with the cases around them: wrong password, nothing typed, a name one character too long, Create pressed twice, another editor opening the item's address, and more
The green line is what the demo shows. The boxes below are what users also do.

Real users are not on the green line for long. The unhappy path is where they spend their day. They mistype the password. They press “Create” before typing anything, because the button was there. They paste a title that is too long. They double-click. None of that is exotic. Count how often you did one of those things yourself this week.

Test the happy path first, and test it properly

None of this means skipping the happy path. If the good input fails, nothing else about the feature matters, so it runs first.

But “runs” is not “passes”. A happy-path test that ends at “the button was clicked and no error appeared” proves almost nothing. End it where the result lives: the item’s page shows the name that was typed, and the list has one more row. We wrote about tests that skip this in hollow passes.

Then five edge case examples

You can’t test every possible input. You don’t have to. For a step where the user types or chooses something, five cases cover the usual breaks:

1. Empty. Press the button with nothing typed. The cheapest case there is, and it finds blank records, crash pages and dead ends. See the empty form.

2. Wrong format. One value of the wrong shape for each field that promises a shape: an email with no @, letters in a number field. See wrong-format inputs.

3. At the limit. If a field has a least or a most, try the limit and one step past it. See boundary values.

4. Wrong, then right. Make a mistake, fix it, send again. This tests the form after an error, which is the state it is least tested in. See wrong, then right.

5. As someone else. Do the same step as another kind of user. In our practice app a viewer can see the list, but their “New item” button is disabled, and the form’s address refuses them. An item belongs to the editor who made it, so another editor who opens its address must get the not-found page.

Five cases, each a minute by hand. Not every one applies to every step. A button with no fields has no wrong format. A field with no limit has no boundary. Skip what doesn’t apply and don’t invent a case to fill the row.

Why these five and not fifty

Each of the five breaks a different assumption the code makes:

CaseThe assumption it breaks
Empty“There will be a value.”
Wrong format“The value will be the kind I expect.”
At the limit“The value will be a normal size.”
Wrong, then right“The form is fresh.”
As someone else“The person is allowed to be here.”

Fifty random strings mostly break the second assumption fifty times. That is why a long list of inputs feels thorough and finds little. One case per assumption finds more than ten cases for one.

There are other assumptions, and for some features they earn a sixth case: “this happens once” (press the button twice), “the person came here the normal way” (open the address directly), “it’s still there later” (reload). Add them where a mistake would cost you something. A double order is worth a case. A double “mark as read” is not.

Where edge cases are not worth it

A sense of proportion helps a small team more than a complete test plan.

  • Pages people only read. A blog post has a happy path and little else. Check it loads and looks right on a phone.
  • Settings almost nobody touches. One good input, one empty, done.
  • Anything you are about to rewrite.

Spend the edge cases on the steps where a break costs money or a user: sign-up, login, checkout, and the main thing people come to your app to do.

How EveryRole splits it

EveryRole draws the same line. At each form in a journey it runs main cases every time: good input, empty, wrong format where a field states a format, and wrong then right once the form has refused something. It also checks each stop as the other kinds of user: does the page open for them, and do they get its button.

Extra cases (too long, the button pressed twice, special characters, a few more) exist for each kind of stop and are off until you turn them on. That is the same judgement call as above, made per form: most steps need the main cases, a few need more.

If you are doing this by hand this week, start with one journey. Run its happy path and look hard at the end result. Then pick the step where a mistake would hurt most and run the five.

Keep reading

Test cases

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.

6 min read