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:
- The bad input is rejected. Nothing is saved, charged or sent.
- The user gets a useful message. It says what went wrong and how to fix it, near the field that caused it.
- The system stays stable. No crash, no 500 page, no stack trace, no frozen spinner.
- 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 testing | Negative testing | |
|---|---|---|
| Question it answers | Does it work with valid input? | Does it fail safely with invalid input? |
| Input | Valid, in range, expected format | Empty, out of range, wrong type, malicious, out of order |
| Expected result | Success: saved, submitted, logged in | Rejection with a clear error, no side effects |
| Example (age field, 18 to 65) | 18, 30, 65 accepted | 17, 66, -1, "abc" rejected |
| Typical share of a suite | Fewer cases, run in every smoke test | More cases, since there are more ways to be wrong |
| What it catches | Broken features | Crashes, bad data, security holes, confusing errors |
| Who forgets it | Rarely skipped | Often 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 class | Example value |
|---|---|
| Below range | 0, -5 |
| Above range | 11, 99999 |
| Not a number | "ten", "5a" |
| Decimal | 2.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 case | Input | Expected result |
|---|---|---|---|
| 1 | Required field empty | Submit form with "Email" blank | Form not submitted; inline error "Email is required" next to the field; other entered values kept |
| 2 | Invalid email format | user@, user.com, user@@site.com | Rejected with format error; no account or record created |
| 3 | Above max length | 256 characters in a 255-character name field | Input blocked at 255 or clear length error; no silent truncation that changes data |
| 4 | Wrong data type | abc in a numeric "Quantity" field | Rejected or prevented by input type; no 500 error |
| 5 | Out-of-range number | 0 and 11 where range is 1 to 10 | Both rejected with message stating the allowed range |
| 6 | Script and SQL injection text | <script>alert(1)</script> and ' OR '1'='1 in a comment field | Stored as plain text or rejected; never executed or rendered as HTML; no database error shown |
Authentication (7 to 11)
| # | Negative case | Input | Expected result |
|---|---|---|---|
| 7 | Wrong password | Valid email, wrong password | Generic error such as "Invalid email or password"; no hint which field was wrong |
| 8 | Unregistered email | Email that has no account | Same generic message and similar response time as case 7, so attackers cannot tell which accounts exist |
| 9 | Repeated failed logins | Wrong password 5+ times (use your lockout threshold) | Account throttled, locked or CAPTCHA shown per policy; password reset still reachable |
| 10 | Expired reset link | Open 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 |
| 11 | Direct URL without login | Open /account/settings in a private window | Redirect 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 case | Input | Expected result |
|---|---|---|---|
| 12 | Generic decline | Stripe test card 4000000000000002 | "Your card was declined" style message; order not created; cart intact; user can retry with another card |
| 13 | Insufficient funds | Stripe test card 4000000000009995 | Decline message shown; no confirmation email; inventory not reserved permanently |
| 14 | Expired card | Stripe test card 4000000000000069 | Clear expired-card error; user can edit card details without re-entering the address |
| 15 | Incorrect CVC | Stripe test card 4000000000000127 with any 3-digit CVC | CVC error shown at the CVC field; no charge |
| 16 | Double submit | Click "Pay" twice quickly, or refresh during processing | Exactly 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 case | Input | Expected result |
|---|---|---|---|
| 17 | File too large | 26 MB file where limit is 25 MB | Rejected before or right after upload with the limit stated; no partial file stored |
| 18 | Disallowed type | .exe renamed to .jpg, or a .svg with embedded script | Rejected based on content, not just extension; script never executes when file is viewed |
| 19 | Empty file | 0-byte .pdf | Clear "file is empty" error; no broken record created |
| 20 | Interrupted upload | Kill network halfway through a large upload | Upload 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 case | Input | Expected result |
|---|---|---|---|
| 21 | Malformed JSON | Body {"name": "Ann", (missing brace) | 400 Bad Request with a parse error message; no stack trace in the body |
| 22 | Missing required field | Valid JSON without email | 400 or 422 naming the missing field; nothing created |
| 23 | No auth token | Request without Authorization header | 401 Unauthorized; no data in body |
| 24 | Valid token, wrong user | User A's token requesting User B's order /orders/123 | 403 Forbidden or 404 Not Found; never User B's data |
| 25 | Wrong content type | JSON body sent as text/plain, or XML to a JSON-only endpoint | 415 Unsupported Media Type |
| 26 | Rate limit exceeded | 200 requests in one second to a limited endpoint | 429 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 case | Input | Expected result |
|---|---|---|---|
| 27 | Session expired mid-task | Let session time out, then submit a long form | Redirect to login with a clear message; ideally the form data is kept or the user is warned before timeout |
| 28 | Logged out in another tab | Log out in tab A, click "Save" in tab B | Action refused and user sent to login; no save under a dead session |
| 29 | Offline submit | Turn off network, click "Submit" | Visible "You're offline" or retry message; no infinite spinner; no duplicate when the network returns |
| 30 | Slow or failing backend | Throttle to slow 3G, or have the server return 503 | Loading 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?
| Priority | Area | Why | Run when |
|---|---|---|---|
| P1 | Money: payments, refunds, double submit | Direct financial loss and support cost | Every build |
| P1 | Security: auth, access control (case 24), injection | Data breach, compliance exposure | Every build |
| P1 | Data integrity: partial saves, corrupt uploads | Hard to undo after the fact | Every build |
| P2 | Session and network errors | Common on mobile and slow networks; causes lost work | Nightly |
| P2 | Common user mistakes: wrong formats, empty fields | High frequency, moderate harm | Nightly |
| P3 | Rare edge values, cosmetic error wording | Low harm | Before 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 .




