Skip to content
Tutorials Center
My learning

Topics

Lesson 53 of 60 ยท Real-World Projects

Project: Test a Login Form

A hands-on testing project: analyse login requirements, derive cases with equivalence partitions, boundaries and error guessing, run them and file bug reports.

A login form looks like the simplest feature in the world: two boxes and a button. That is exactly why it makes a great first project. It has real rules, real boundaries, security implications and plenty of room for small bugs. In this project you will do the whole job a tester does on a small feature: study the requirements, design test cases with the techniques from the previous chapters, run them, and write up what you found.

The login form itself is a stand-in: a small JavaScript function that behaves like a login backend and has five bugs planted in it. You will not see the bugs in advance; you will find them through your tests, just as you would on a real product. No real website, account or password is involved. If you want to review the techniques first, see equivalence partitioning, boundary value analysis and experience-based testing.

Step 1: analyse the requirements

Here is the specification the team gave us. Read it like a tester: underline every rule, and look for what is missing.

  • R1: The username must be 3 to 12 characters long and contain only letters and digits. Usernames are not case sensitive.
  • R2: The password must be 8 to 20 characters long and contain at least one letter and at least one digit.
  • R3: If the username or password breaks the format rules, show a specific message: "Username must be 3-12 letters or digits" or "Password must be 8-20 characters with a letter and a digit".
  • R4: If the format is fine but the credentials are wrong, show one generic message for both an unknown user and a wrong password: "Invalid username or password". This must not reveal which part was wrong.
  • R5: After 3 consecutive failed logins for an account, lock it: "Account locked. Try again later." A successful login resets the failure count.
  • R6: A successful login shows "Welcome, " followed by the username in lowercase.

A quick requirements review already raises questions you would ask the product owner: how long is the lock? What if the username is valid but the password is empty? Is a leading space trimmed? Is the check order (username, password, lock, credentials) intended? In this project we assume the order above. Asking these questions early is the cheapest testing there is; see reviewing requirements for testability.

Plan of attack

Read Underline every rule.
Partition Valid and invalid groups.
Boundaries Test both sides of each limit.
Guess Try what developers forget.

Then run, compare, and report.

1 / 2

Step 2: partitions and boundaries

Apply equivalence partitioning to each input.

Input Valid partition Invalid partitions
Username 3-12 letters or digits too short, too long, forbidden characters, empty
Password 8-20 chars with a letter and a digit too short, too long, no digit, no letter
Credentials (format OK) known user with correct password known user with wrong password, unknown user
Attempts fewer than 3 failures 3 consecutive failures

Then boundary value analysis on the two length rules, testing the last invalid value and the first valid value on each side:

Rule Just outside Just inside
Username length 2 and 13 3 and 12
Password length 7 and 21 8 and 20

Finally error guessing, based on what usually goes wrong with login forms:

  • an empty username, a username with a quote or spaces (typical injection-style characters; see security testing basics),
  • a password made only of spaces,
  • the right username in a different case, since R1 says it is case insensitive,
  • the lockout: does it trigger on exactly the third failure, and does a success reset the counter?

That gives us 19 test cases. Notice how few were needed: each one targets a specific partition, boundary or guess.

Step 3: run the cases

The stand-in login function and the cases are below. Each case lists its attempts (one or several, for the lockout checks) and the expected message, taken from the requirements, not from what the code happens to do. That discipline matters: deriving the expected result from the code only proves the code equals itself. Each case runs against a fresh login system so tests stay independent.

JS Run the login test cases

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Six cases fail. Compare each failing case with the requirements and ask what rule it breaks:

  • T03 and T05 return "Unknown user" for a username that does not exist. R4 demands the generic message. This is a security weakness: an attacker can find out which usernames are real.
  • T06 rejects a valid 12-character username. The upper boundary of R1 is off by one.
  • T11 lets a 21-character password pass the format check, so R2's upper boundary is off by one too.
  • T17 (ALICE) fails with "Unknown user". R1 says usernames are case insensitive, so this is a defect. Notice that it also shows the leaky message again; one root cause, one message.
  • T18 lets the user log in on the fourth attempt. R5 says the account locks after three failures, so the correct password on attempt four must be refused.

The passing cases matter too. T09 and T10 show that the lower password boundary and a length of 20 are handled, and T19 shows that a success does reset the counter. Not every boundary test finds a bug, and that is normal: a passing boundary test is evidence, not wasted effort. Notice also that the bugs were found by deliberate boundary and rule cases, which echoes the seven testing principles: defects cluster at limits, and exhaustive testing was never needed.

Step 4: file the bug reports

Five distinct problems were found (T03 and T05 share a cause, and T17 is a different cause that also shows the same leaky message). Each deserves its own report, written so a developer can reproduce it without asking you anything. The structure follows writing excellent bug reports: a clear title, steps, expected versus actual, and a severity and priority with a one-line reason.

The next stand-in holds the five findings as data (copied from the run above), lints each report for missing parts, prints it in a readable format and proposes a fix order. A real team would do this in a tracker such as Jira, but the content is the same.

JS Bug reports and a fix order

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Severity describes how bad the effect is; priority describes how soon to fix it. They are different judgments. The lockout bug is both severe and urgent because it weakens protection against password guessing. The 12-character username bug is real but affects few users, so it is low severity; it gets medium priority because it is an easy fix that blocks some customers entirely. Your team's triage meeting makes the final call (defect lifecycle covers how reports move on from here).

Step 5: what you would do next

A good tester does not stop when the planned cases are done. Think about what is still untested:

  • Retesting and regression: once the developers fix the five bugs, re-run T03, T05, T06, T11, T17 and T18 (confirmation testing), then run the other 13 cases again to be sure nothing else broke (regression testing).
  • Things this stand-in cannot show: how the form looks and behaves on a phone, tab order and screen-reader labels (see web UI, usability and accessibility checks), whether the password field masks its characters, what the browser's Back button does after logging in, and whether passwords travel over HTTPS.
  • Non-functional checks: how many logins per second the system handles, and what happens when the user database is down (performance and reliability testing).
  • Unanswered questions from the requirements review: the lock duration, trimming of spaces, password reset flow, "remember me".
  • Automation candidates: the 19 cases are deterministic and cheap, so they would become a small automated regression suite, as discussed in when and what to automate.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Why should the expected result of each test case come from the requirements and not from the code's current behavior?

    A test oracle must be independent of the thing under test. If the expected result is copied from the code, every bug would pass as correct.
  2. 2. A login form has a username limit of 3 to 12 characters. Which values are the boundary values to test?

    Two-value BVA uses the last invalid and first valid value on each side of every limit: 2 and 3 at the lower end, 12 and 13 at the upper end.
  3. 3. Why is the message 'Unknown user' a defect when the requirement asks for one generic message?

    Different messages for unknown users and wrong passwords let attackers confirm valid accounts. The requirement exists for security.
  4. 4. After the developers fix the lockout bug, what is the best next step?

    Confirmation testing proves the specific fix works; regression testing checks that nothing else in the area broke.
  5. 5. Three consecutive failed logins should lock the account, but the system locks only after four. What does this show about the test design?

    Rules about counts need multi-step cases. The boundary idea (exactly 3, not 2 or 4) applies to counts and sequences as well as to lengths.

Summary

  • Start from the requirements: list every rule and question what is missing before designing anything.
  • Combine equivalence partitions, boundary values and error guessing; a few well-chosen cases (here 19) cover a lot.
  • Derive expected results from the requirements, never from the code under test.
  • Failing cases map back to broken rules; passing boundary cases are still useful evidence.
  • Write reproducible bug reports with expected versus actual, separate severity from priority, then retest and run regression after fixes.

Next: Project: Test a Shopping Cart.