Testing fundamentals

Negative Testing: What It Is, Techniques and 30 Test Case Examples

Robonito TeamRobonito Team 13 min read
Negative Testing: What It Is, Techniques and 30 Test Case Examples

A tester signs off a checkout flow on Friday. Every happy path passes. On Monday a customer pastes a card number with spaces, double-clicks "Pay", and gets charged twice. Nobody wrote a test for that, because nobody asked "what if the user does it wrong?"

That question is the whole job of negative testing.

Updated December 2026

Negative testing checks how software behaves when it gets invalid, unexpected or hostile input, such as empty fields, wrong data types, expired tokens or dropped connections. A good negative test expects a clear error, no crash, no data corruption and no security leak. It complements positive testing, which confirms the software works with valid input.

Key takeaways

  • Every requirement needs at least one positive and one negative test. Happy paths alone leave half the behavior unchecked.
  • Three techniques produce most negative cases: boundary values, invalid equivalence classes and error guessing.
  • The 30 examples below are grouped by area (forms, login, payments, uploads, APIs, session) with input and expected result, ready to copy.
  • Prioritize negative cases by risk: money, security and data loss first, cosmetic validation last.

What is negative testing?

Negative testing, also called failure testing or error path testing, feeds a system input it should reject and checks that it rejects it properly. Wikipedia's definition puts it simply: the goal is to see whether the system can handle unexpected or invalid input.

"Properly" is the important word. A negative test does not pass just because the app refused the input. It passes when four things are true:

  1. The bad input is rejected. Nothing is saved, charged or sent.
  2. The user gets a useful message. It says what went wrong and how to fix it, near the field that caused it.
  3. The system stays stable. No crash, no 500 page, no stack trace, no frozen spinner.
  4. Nothing leaks. The error does not reveal internal paths, SQL, or whether an account exists.

Happy paths get demoed and clicked every day. Error paths often run for the first time in front of a customer. That is why negative scenarios in testing deserve their own place in the test plan, not a line at the end.

What is the difference between positive and negative testing?

Positive testing proves the software does what it should. Negative testing proves it does not do what it should not. As TechTarget's comparison notes, the key difference is the input; both kinds still compare actual behavior to an expected result.

Positive testingNegative testing
Question it answersDoes it work with valid input?Does it fail safely with invalid input?
InputValid, in range, expected formatEmpty, out of range, wrong type, malicious, out of order
Expected resultSuccess: saved, submitted, logged inRejection with a clear error, no side effects
Example (age field, 18 to 65)18, 30, 65 accepted17, 66, -1, "abc" rejected
Typical share of a suiteFewer cases, run in every smoke testMore cases, since there are more ways to be wrong
What it catchesBroken featuresCrashes, bad data, security holes, confusing errors
Who forgets itRarely skippedOften skipped under deadline pressure

You need both. Positive and negative testing together give you coverage of a requirement; either alone leaves half the behavior unverified. Smoke tests are usually positive only, while regression testing should carry the negative cases that have caught real bugs before.

Which techniques find the best negative cases?

You do not need a long list of methods. Three techniques generate most useful cases, and they work best together.

Boundary value analysis

Bugs cluster at the edges of ranges. If a field accepts 1 to 100 characters, test 0, 1, 100 and 101. The values just outside the range (0 and 101) are your negative cases. They catch off-by-one mistakes, such as a developer writing < where the rule needed <=.

Invalid equivalence classes

Split all possible inputs into groups that the system should treat the same way, then pick one value from each group. For a quantity field that takes whole numbers 1 to 10, the invalid classes are:

Invalid classExample value
Below range0, -5
Above range11, 99999
Not a number"ten", "5a"
Decimal2.5
Empty""
Special characters"

One value per class covers the class. Testing -5 and -6 adds nothing that -5 did not already prove.

Error guessing

This is experience written down. Testers who have seen many bugs know the usual suspects: double clicks, back button after submit, pasted text with trailing spaces, emoji in name fields, two tabs open at once, a session that expired mid-form. Keep a team list of these and add to it after every escaped bug.

State transition testing, fuzzing and exploratory sessions also help (GeeksforGeeks lists eight techniques), mainly for features with complex states or untrusted input.

What are 30 negative test case examples?

Here are 30 negative testing examples grouped by area. Each has an input and an expected result you can adapt. Replace the limits (lengths, sizes, attempt counts) with the ones in your own requirements.

Forms and input (1 to 6)

#Negative caseInputExpected result
1Required field emptySubmit form with "Email" blankForm not submitted; inline error "Email is required" next to the field; other entered values kept
2Invalid email formatuser@, user.com, user@@site.comRejected with format error; no account or record created
3Above max length256 characters in a 255-character name fieldInput blocked at 255 or clear length error; no silent truncation that changes data
4Wrong data typeabc in a numeric "Quantity" fieldRejected or prevented by input type; no 500 error
5Out-of-range number0 and 11 where range is 1 to 10Both rejected with message stating the allowed range
6Script and SQL injection text<script>alert(1)</script> and ' OR '1'='1 in a comment fieldStored as plain text or rejected; never executed or rendered as HTML; no database error shown

Authentication (7 to 11)

#Negative caseInputExpected result
7Wrong passwordValid email, wrong passwordGeneric error such as "Invalid email or password"; no hint which field was wrong
8Unregistered emailEmail that has no accountSame generic message and similar response time as case 7, so attackers cannot tell which accounts exist
9Repeated failed loginsWrong password 5+ times (use your lockout threshold)Account throttled, locked or CAPTCHA shown per policy; password reset still reachable
10Expired reset linkOpen a password reset link after it has expired or been used once"Link expired" message and option to request a new one; password not changed
11Direct URL without loginOpen /account/settings in a private windowRedirect to login; after login, return to the requested page; no data flashed before redirect

The generic-message rule in cases 7 and 8 comes straight from the OWASP Authentication Cheat Sheet, which also says response time should not reveal whether an account exists. For a full login suite, see our sibling post on test cases for a login page.

Payments and checkout (12 to 16)

Payment gateways give you test cards that trigger specific failures, so you never need a real declined card. The numbers below are from Stripe's testing docs and only work in Stripe test mode; other gateways publish their own.

#Negative caseInputExpected result
12Generic declineStripe test card 4000000000000002"Your card was declined" style message; order not created; cart intact; user can retry with another card
13Insufficient fundsStripe test card 4000000000009995Decline message shown; no confirmation email; inventory not reserved permanently
14Expired cardStripe test card 4000000000000069Clear expired-card error; user can edit card details without re-entering the address
15Incorrect CVCStripe test card 4000000000000127 with any 3-digit CVCCVC error shown at the CVC field; no charge
16Double submitClick "Pay" twice quickly, or refresh during processingExactly one charge and one order; button disabled after first click

Case 16 is classic error guessing, and it is where duplicate charges come from. Check the order list and the gateway dashboard, not just the screen.

File upload (17 to 20)

#Negative caseInputExpected result
17File too large26 MB file where limit is 25 MBRejected before or right after upload with the limit stated; no partial file stored
18Disallowed type.exe renamed to .jpg, or a .svg with embedded scriptRejected based on content, not just extension; script never executes when file is viewed
19Empty file0-byte .pdfClear "file is empty" error; no broken record created
20Interrupted uploadKill network halfway through a large uploadUpload fails cleanly with retry option; no corrupt file attached to the record

APIs (21 to 26)

API negative tests check status codes and response bodies, not screens. The meanings below follow MDN's HTTP status reference. Your API may use slightly different codes; the test is that it uses the documented one consistently.

#Negative caseInputExpected result
21Malformed JSONBody {"name": "Ann", (missing brace)400 Bad Request with a parse error message; no stack trace in the body
22Missing required fieldValid JSON without email400 or 422 naming the missing field; nothing created
23No auth tokenRequest without Authorization header401 Unauthorized; no data in body
24Valid token, wrong userUser A's token requesting User B's order /orders/123403 Forbidden or 404 Not Found; never User B's data
25Wrong content typeJSON body sent as text/plain, or XML to a JSON-only endpoint415 Unsupported Media Type
26Rate limit exceeded200 requests in one second to a limited endpoint429 Too Many Requests, ideally with Retry-After; service stays up for other clients

Case 24 is easy to miss because each user's own tests pass, and it is a real security bug when it fails. Test it on every endpoint that takes an ID. Our guide to API test automation tools covers how teams run these at scale.

Session and network (27 to 30)

#Negative caseInputExpected result
27Session expired mid-taskLet session time out, then submit a long formRedirect to login with a clear message; ideally the form data is kept or the user is warned before timeout
28Logged out in another tabLog out in tab A, click "Save" in tab BAction refused and user sent to login; no save under a dead session
29Offline submitTurn off network, click "Submit"Visible "You're offline" or retry message; no infinite spinner; no duplicate when the network returns
30Slow or failing backendThrottle to slow 3G, or have the server return 503Loading state, then a friendly error with retry; no blank page

The OWASP Session Management Cheat Sheet says logout must invalidate the session on the server, not just delete the cookie. Case 28 is how you check that from the outside.

How do you prioritize negative cases?

There are always more negative cases than time. A field with ten validation rules can produce fifty negative tests. Rank them with two questions: what happens if this fails in production, and how likely is a real user to trigger it?

PriorityAreaWhyRun when
P1Money: payments, refunds, double submitDirect financial loss and support costEvery build
P1Security: auth, access control (case 24), injectionData breach, compliance exposureEvery build
P1Data integrity: partial saves, corrupt uploadsHard to undo after the factEvery build
P2Session and network errorsCommon on mobile and slow networks; causes lost workNightly
P2Common user mistakes: wrong formats, empty fieldsHigh frequency, moderate harmNightly
P3Rare edge values, cosmetic error wordingLow harmBefore release, or exploratory

Two more rules help:

  • Turn every escaped bug into a negative test. If production broke on an emoji in a name field, that case goes into the regression suite permanently.
  • Do not test the same class twice. One invalid email format per invalid class is enough at the UI layer. Push detailed format coverage down to unit or API tests, where it is cheaper.

If your team is new to structured test design, our guide on how to write test cases in manual testing covers the basic format these tables follow.

How do you automate negative test cases?

Negative cases are repetitive and data-driven, which makes them good automation candidates.

Use data-driven tests. Write one test, feed it a table of invalid inputs and expected messages. Cases 1 to 5 above become one test with five rows. SmartBear's guidance makes the same point: mix valid and invalid values in data files and generate boundary values just inside and just outside limits.

Assert the absence of side effects. A negative UI test that only checks for an error message is half a test. Also check that no record was created, no email was sent and no charge was made. For APIs, assert the status code and that the body has no stack trace.

Test at the cheapest layer. Validation rules belong in unit and API tests. Keep UI negative tests for things only the UI can show: inline messages, disabled buttons, redirects, double clicks.

Control the environment. Network, session and rate-limit cases need you to throttle the network, expire tokens or fake server errors. Most browser automation tools can throttle or intercept network requests; use that instead of waiting for real timeouts.

Use gateway test modes. Never point automated payment tests at live keys. Use the gateway's sandbox and its published decline cards.

Keep them in regression. Negative cases that guard money and security should run on every build. See automated regression testing for how to structure that suite.

A reusable negative test template

Copy this for any new field or endpoint:

Feature:            [e.g. Checkout > Card payment]
Requirement:        [e.g. Card must be valid and authorized]
Negative case ID:   NEG-PAY-03
Technique:          [Boundary | Invalid class | Error guessing]
Precondition:       [e.g. Cart has 1 item, user logged in, gateway in test mode]
Input:              [exact invalid value]
Steps:              1. ... 2. ... 3. ...
Expected (UI):      [message text and where it appears]
Expected (system):  [no order created, no charge, no email]
Must not happen:    [crash, 500, stack trace, data leak, duplicate]
Priority:           [P1 | P2 | P3]
Automate?:          [Yes - layer: unit | API | UI]

The "Must not happen" line is what separates a strong negative test from a weak one.

Where does Robonito fit in negative testing?

Robonito is an agentic QA platform: AI agents create, run and maintain end-to-end tests. Here is where it helps with this work, and where it does not.

Where it helps:

  • Generating cases from requirements. In AI Studio you can describe what to test in plain English, paste a URL or reference a Jira issue. AI Studio can also generate tests from requirement documents, Jira stories and epics, Swagger/OpenAPI definitions and the live app. That is a quick way to get a first draft of negative scenarios for a feature, which your team then reviews and trims. Our roundup of AI test case generation tools compares this approach with others.
  • Keeping UI negative tests alive. Error messages and form layouts change often. Robonito's self-healing steps adapt when labels, layouts or locators change, and healed steps are logged for review.
  • Seeing why a negative test failed. Every run keeps video, network traces and an AI root cause for failures, which matters when the bug is "the error never appeared" or "the request returned 500".
  • API negative cases. API testing, including importing Postman collections, is on the Pro and Enterprise plans.

Where it is not the right tool:

  • Unit-level validation tests belong in your codebase and your unit test framework.
  • Robonito is not a test management tool. If you track hundreds of negative cases with owners and statuses, keep them in TestRail, Zephyr or Xray (Robonito integrates with these) or your existing tool.
  • Fuzzing parsers with millions of random inputs is a job for a dedicated fuzzer.

Web test automation and plain-text test creation are on every plan, including Free. See pricing for plan limits.

or to see AI Studio draft negative cases from one of your own Jira stories.

Frequently asked questions

What is negative testing in simple words?

Negative testing means trying to use software the wrong way on purpose, for example leaving fields empty, typing letters into number fields, or using an expired login, and checking that it fails safely with a clear error instead of crashing or saving bad data.

What is an example of a negative test case?

Entering user@ in an email field and clicking Submit. The expected result is that the form is not submitted, an inline "Enter a valid email" message appears, and no record is created. See the 30 negative test cases above for more.

How many negative test cases should I write per feature?

There is no fixed number. Cover each invalid equivalence class once, each boundary just outside the range, and the error-guessing cases that apply. For a typical form that is often 5 to 15 negative cases, more for payments and auth.

Is negative testing the same as security testing?

No, but they overlap. Many negative scenarios in testing, such as injection text, access to another user's data and brute-force login, are also security checks. Security testing goes further, with threat modeling and dedicated tools.

Should negative tests be automated?

Yes, for anything that guards money, security or data integrity, and for validation that rarely changes. Keep one-off edge cases for exploratory sessions. Run automated negative cases as part of your regression suite.

What is the ratio of positive to negative test cases?

Most teams end up with more negative than positive cases, because there is usually one right way to complete a task and many wrong ways. Aim for at least one negative case per requirement, then add more where risk is high.


Want a first draft of negative cases for your next feature? or .

Free whitepaperThe Agentic QA PlaybookMove from test scripts to AI agents in 90 days, with the controls, metrics and a 25-question vendor checklist.

No-code AI test automation

Spend less time testing and more time shipping.

3Pillar showed Robonito's agents to its own client live, and that client is now onboarding. Start on the Free plan, which stays free forever, or book a demo and we'll walk through your own app.

Newsletter

Get new posts by email

Practical guides on software testing, QA automation and AI agents. One email when we publish, no spam.

We'll send a confirmation email first. Your details are stored with Mailchimp, our email provider.

All blog posts