Skip to content
Tutorials Center
My learning

Topics

Lesson 22 of 60 ยท Test Design Techniques

Positive and Negative Testing, Error Guessing

Learn positive and negative testing with examples, how they relate to valid and invalid input, and how to use error guessing to find the nasty cases.

Every feature has a happy path: the user types valid data, clicks the right buttons and gets the result they expect. It is natural to test that first. But users make mistakes, networks fail and attackers type strange things. A product that works only when everyone behaves perfectly is not a good product. Two complementary mindsets keep you honest: positive testing and negative testing. Both use inputs you choose with techniques you already know, plus a hunch-driven technique called error guessing.

Positive testing

Positive testing checks that the software does what it should when given valid input and used as intended. The aim is to confirm expected behavior: the required function works, produces the correct result and moves to the right next state.

Examples for a registration form:

  • Register with a valid email and a strong password: account is created and a confirmation email arrives.
  • Use the maximum allowed username length (say 20 characters): it is accepted.
  • Log in with the correct credentials: dashboard opens.

Positive tests answer "can it work?". They are usually written first, and they are the backbone of smoke and acceptance checks.

Negative testing

Negative testing checks that the software handles invalid, unexpected or hostile input and conditions gracefully: it must reject them or recover, give a clear message, and never crash, corrupt data or leak secrets. The aim is not to make the invalid input succeed. The aim is for the system to fail safely.

Examples for the same form:

  • Register with an email missing the @: a clear error appears next to the field; no account is created.
  • Leave the password empty; use a 5-character password; use 200 characters.
  • Submit the form twice quickly; submit while offline.
  • Try to log in with a wrong password ten times: the account is locked or throttled.
  • Open a protected URL without being signed in: you are sent to the login page, not shown the data.

Negative tests answer "does it break safely?". They are often where the serious defects hide, including security problems (see Security Testing Basics).

Positive Negative
Input Valid Invalid, missing, extreme, wrong type
Expected result Feature works Rejection, error message or safe recovery
Question Can it work? Can it fail safely?
Typical bugs Wrong calculation, missing step Crash, data loss, vague message, security hole

Notice how the techniques fit: equivalence partitioning gives you one valid and several invalid classes; boundary value analysis gives the edges on both sides. Valid partitions lead to positive tests, invalid ones to negative tests.

What a good negative test checks

Do not stop at "it did not crash". For each negative case verify:

  1. The invalid action was rejected (nothing was saved or changed).
  2. The message is clear, specific and kind, with no stack trace, SQL or internal path.
  3. The user keeps the valid data they already typed.
  4. The system remains usable and consistent afterwards.
  5. The event is logged where appropriate.

Error guessing

Techniques give you structure, but they cannot list every way things go wrong. Error guessing uses the tester's experience, intuition and knowledge of common mistakes to predict where defects hide and to design tests for those spots. It is formally an experience-based technique (see Experience-Based Testing); here is how it connects to negative testing.

A practical process:

  1. Collect past knowledge. Review earlier bug reports, support tickets and post-mortems for this product and similar ones.
  2. Build a fault list (a checklist). Group common failures by input type: text, numbers, dates, files, time, concurrency.
  3. Pick items by risk and likelihood for the feature in hand.
  4. Design a test for each, run it, and record any result.
  5. Update the list with what you learned.

A starter fault list:

  • Text: empty, spaces only, very long, leading/trailing spaces, Unicode, emoji, right-to-left text, quotes, <script>, SQL characters, control characters.
  • Numbers: zero, negative, decimals, huge, NaN-like text, scientific notation, thousands separators.
  • Dates: 29 February, 31 April, year 0 or 9999, time zones, daylight-saving jumps, past dates where future ones are required.
  • Files: zero bytes, huge, wrong extension, corrupt, special characters in the name.
  • State: double click, back button after submit, session timeout, two tabs.
  • Environment: no network, slow network, full disk, low memory, different locale.

Try it: a negative-test generator

This stand-in produces typical negative inputs for different field types and runs them against a validator, flagging cases that are wrongly accepted or that crash.

JS Negative inputs against a validator

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

No output.

The results show the validator wrongly accepts "1.5" (an age is an integer) and "1e9" is rejected only because of its size. Negative tests found these gaps; a positive-only suite would pass every time. Try adding the dates to a validator of your own.

Try it: positive and negative cases from partitions

Turn the partitions of one field into a balanced list of cases, labelled positive or negative, and execute them against a corrected validator.

JS Balanced positive and negative cases

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

No output.

A common ratio in real suites is more negative than positive cases, because there are many more ways to be wrong than right.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A tester enters letters into a quantity field and expects an error message. What kind of test is this?

    Invalid input with the expectation of graceful rejection is a negative test.
  2. 2. What is the goal of a negative test?

    The software must fail safely: reject the input, give a clear message and stay consistent.
  3. 3. Which is a good source for an error-guessing checklist?

    Real past failures show where this product and similar ones tend to break.
  4. 4. Which pair is a correct link between techniques and test kinds?

    Valid classes give positive tests, invalid classes give negative tests; boundaries matter on both sides.

Summary

  • Positive testing confirms that valid input works; negative testing confirms that invalid input or conditions are handled safely.
  • A good negative test checks rejection, message quality, preserved valid data, consistency and logging.
  • Equivalence partitions and boundaries supply both kinds of cases.
  • Error guessing turns experience and past defects into a risk-ranked fault list.

Next up: Cause-Effect Graphing.