---
description: NEGATIVE TESTING is a software testing type that checks a system for unexpected input data and conditions. Unexpected conditions can be anything from a wrong data type to a strong hacking attack. The purpose of negative testing is to prevent applications from crashing due to negative inputs.
title: What is Negative Testing? Test cases With Example
image: https://www.guru99.com/images/what-is-negative-testing.png
---

 

[Skip to content](#main) 

**⚡ Smart Summary**

Negative Testing checks how a software application behaves when it receives unexpected input data or operating conditions, so the product degrades gracefully instead of crashing, corrupting data or exposing a security hole.

* 🔴 **Purpose:** Confirm the application rejects invalid data cleanly instead of failing or crashing.
* ⚖️ **Contrast:** Positive testing proves the happy path; negative testing probes everything outside it.
* 🛗 **Analogy:** A lift must survive overload, fire and power loss, not only normal passenger trips.
* 🔒 **Security:** Invalid uploads and SQL injection attempts are classic negative test scenarios.
* 🧪 **Design:** Boundary values, equivalence classes, error guessing and fuzzing generate the cases.
* 📊 **Priority:** Rank invalid inputs by impact, because exhaustive negative coverage is unaffordable.
* ⚠️ **Trade-off:** Excessive negative testing consumes budget that positive coverage may need more.

[ Read More ](javascript:void%280%29;) 

![Negative Testing in software testing with invalid input examples](https://www.guru99.com/images/what-is-negative-testing.png) 

## Negative Testing

**Negative Testing** is a software testing type used to check a software application against unexpected input data and conditions. Unexpected data or conditions range from a wrong data type in a simple form field to a deliberate hacking attack. The purpose of negative testing is to prevent the application from crashing on invalid input and to improve the quality and stability of the product.

Positive testing alone only proves that the system works under normal conditions. Negative testing confirms that the same system also handles abnormal conditions, which is what a fault-tolerant product requires.

## Example of Negative Testing

A lift is the example most often used to explain negative testing, because its normal behaviour and its failure behaviour are both easy to picture.

The requirements of a lift are familiar: pressing a floor number sends the lift to that floor, and the door opens automatically once the lift reaches the specified floor.

Some negative scenarios for the same lift are listed below, next to the assumption that positive testing makes instead.

| Negative Testing                                                            | Positive Testing                                                 |
| --------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| What happens if the number of persons (weight) exceeds the specified limit? | Assumes only the specified number of persons will enter the lift |
| What happens if someone smokes or causes a fire inside the lift?            | Assumes there will be no smoke or fire inside the lift           |
| What happens if there is a power failure during operation?                  | Assumes there will be no power failure while the lift is working |

All of these cases fall under negative testing. None of them can be guaranteed never to happen, so each one has to be contained.

Suppose the overweight condition is never checked, and the lift behaves abnormally once it is overloaded. That single gap damages the reliability of the system and can even endanger life. This is what negative testing means in practice, and why it matters.

Software behaves the same way. A negative test deliberately deviates from the normal operational procedure. Consider a registration form.

| Negative Testing                                                                                                                                       | Positive Testing                                            |
| ------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- |
| Enter an invalid email id in the email field                                                                                                           | Only valid email ids are entered in an email field          |
| Enter an invalid phone number, such as characters, in a phone number field                                                                             | Only numbers are entered in the number field                |
| Upload an image with a size outside the specified boundary                                                                                             | Only images within the specified size boundary are uploaded |
| Upload invalid files such as [XML](https://www.guru99.com/xml-tutorials.html) or [SQL](https://www.guru99.com/sql.html) files in an image upload field | Only valid image formats such as .jpg or .png are uploaded  |

Each of these negative cases must still leave the system working. If a character is typed into a number field, the application cannot process the unexpected data it was never expecting, and it may crash. Worse, an [SQL injection](https://www.guru99.com/learn-sql-injection-with-practical-example.html) string in the same field could erase the contents of the database. Losses of that kind are the reason negative testing exists.

## Why do Negative Testing?

Testing consumes time and money, so deciding what, how and how much to test matters. The case for spending part of that budget on negative testing looks different from the two sides of a project.

### Organization perspective

Delivering a good quality product to the client is the responsibility of the organization, and negative testing is part of that obligation. It is also the organization’s evidence that it did everything reasonable to prevent a failure, even though no system is completely error free.

Impact is the deciding factor. An e-commerce site may pass every positive test and still contain a loophole that lets an attacker run an SQL injection and erase the data behind it. That is a serious security breach, and only negative testing looks for it.

Public-facing applications, websites in particular, offer almost no control over how visitors use them, so negative testing is the only way to confirm that unusual usage is covered and contained. The same applies to malicious users: attackers actively look for an opportunity to break a system, and hacking scenarios belong squarely in negative test coverage.

### Client perspective

Clients expect a product with zero vulnerabilities, and negative testing is what supports that expectation. For sensitive products such as e-commerce or online stock trading, [security testing](https://www.guru99.com/what-is-security-testing.html) and negative testing are mandatory rather than optional.

The client’s only real concern is cost. Once the impact of a failure is analysed, the client is in a position to decide how far the negative testing effort should go.

### RELATED ARTICLES

* [eCommerce Testing: How to Test an E-Commerce Website ](https://www.guru99.com/testing-e-commerce-applications.html "eCommerce Testing: How to Test an E-Commerce Website")
* [What is Thread Testing in Software Testing? ](https://www.guru99.com/thread-testing.html "What is Thread Testing in Software Testing?")
* [What is Loop Testing? Methodology, Example ](https://www.guru99.com/loop-testing.html "What is Loop Testing? Methodology, Example")
* [Non-Destructive Software Testing (NDT): What is, Test Strategy ](https://www.guru99.com/non-destructive-testing-ndt.html "Non-Destructive Software Testing (NDT): What is, Test Strategy")

## How to do Negative Testing

Negative testing starts by considering every input the application can physically receive, not only the inputs it is supposed to receive. Each of those belongs in a [Test Case](https://www.guru99.com/test-case.html) even when it is obviously the wrong way to use the feature. An email field is tested with everything that is not a valid email address, and an image upload control is tested with every file type that is not an image.

The list of possible invalid inputs is effectively endless, so negative test cases have to be prioritised. For an image field that accepts only .png files, the candidate uploads include .jpeg, .xml, .xls and many others. An XML or SQL file has a far greater potential impact than a .jpeg, so those cases are executed first. Ranking cases by impact before execution is what keeps negative testing affordable.

Most negative test cases come from a small set of established design techniques rather than from improvisation:

* **Boundary values:** exercise the values immediately outside a valid range, such as 0 and 101 for a field that accepts 1 to 100.
* **Invalid equivalence classes:** pick one representative from each class of rejected input, for example letters in a numeric field.
* **Error guessing:** use experience of past defects to target the inputs most likely to break this kind of feature.
* **Malformed and hostile data:** script tags, SQL fragments and oversized payloads that probe validation and security handling.
* **[Fuzz testing](https://www.guru99.com/fuzz-testing.html):** generate large volumes of random or mutated input automatically to find unhandled crashes.
* **Interrupted flows:** cancel, refresh, time out or lose connectivity part-way through a transaction.

Whichever technique produces the case, the expected result must be written down as a controlled, readable failure — a validation message, a rejected upload, a clean rollback — and never merely as “the system does not crash”.

## Pros and Cons of Negative Testing

Like every other testing technique, negative testing has advantages and drawbacks that depend on where, when and how much of it is applied.

### Advantages of Negative Testing

* It protects product quality directly, because a good quality product is one with no exploitable vulnerabilities.
* It widens coverage. Invalid input reaches a live system intentionally or accidentally, so negative cases have to run alongside positive ones for coverage to be meaningful.
* It increases client confidence before a release goes live.
* It surfaces defects that positive testing structurally cannot reach, such as unhandled exceptions and weak input validation.

### Disadvantages of Negative Testing

* In some situations it is a waste of time and energy. If an application is built for a single user, the case of 100 simultaneous users is not worth testing, so choosing the right conditions matters and some systems need very little negative testing at all.
* It requires skilled and experienced people to design the cases.
* From the client’s point of view it adds cost and can delay the release.
* It competes for effort. A team that spends heavily on negative testing may end up under-investing in positive testing.

## FAQs

⚡ How does negative testing differ from positive testing?

Positive testing feeds valid data and confirms the expected result. Negative testing feeds invalid data, wrong formats and broken sequences, and confirms the application rejects them with a controlled message instead of failing.

🧪 What are typical negative test cases for a login form?

Blank credentials, a valid user with a wrong password, SQL fragments in the username, over-length strings, leading or trailing spaces, disabled accounts, and repeated failed attempts to confirm lockout behaviour works.

🔒 Is negative testing the same as security testing?

No. They overlap where invalid or hostile input is involved, but security testing also covers authentication, authorisation, encryption and session handling. Negative testing is a broader input and condition technique.

👥 Who is responsible for writing negative test cases?

Testers and QA engineers usually write them, often with a developer reviewing error paths and a business analyst confirming which invalid conditions the requirements actually forbid.

📊 How much negative testing is enough?

Enough to cover every rejected input class, every boundary and every high-impact failure path. Beyond that, added cases return little value, so risk and impact set the stopping point.

⚙️ Can negative testing be automated?

Yes. Invalid-input cases are highly repeatable, so they suit [automation testing](https://www.guru99.com/automation-testing.html) and regression suites. Fuzzing tools automate random-input generation, while assertions check that validation messages appear.

🤖 How does AI help create negative test cases?

Models read requirements or a form schema and propose invalid values, boundary conditions and hostile strings a tester may not list manually. A reviewer still confirms each expected result matches the specification.

🧑‍💻 Can GitHub Copilot write negative test scripts?

Yes, it drafts assertion code, invalid-data fixtures and parameterised cases from an existing test file. The generated expectations need review, because a plausible-looking assertion can encode the wrong behaviour.

#### Summarize this post with:

ChatGPT Perplexity Grok Google AI 

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.** 

##### Sign up for the newsletter

Subscribe for Free 

You have successfully subscribed.  
Please check your inbox. 

![AI-Newsletter]() Chosen by over **350,000+** professionals 

[Scroll to top ](#wrapper)Scroll to top 

× 

Toggle Menu Close 

Search for: 

Search

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/what-is-negative-testing.png","url":"https://www.guru99.com/images/what-is-negative-testing.png","width":"700","height":"250","caption":"What is Negative Testing?","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/negative-testing.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/softwaretesting","name":"Software Testing"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/negative-testing.html","name":"What is Negative Testing? Test cases With Example"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/negative-testing.html#webpage","url":"https://www.guru99.com/negative-testing.html","name":"What is Negative Testing? Test cases With Example","dateModified":"2026-07-29T12:26:38+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/what-is-negative-testing.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/negative-testing.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/thomas","name":"Thomas Hamilton","description":"I am Thomas Hamilton, a seasoned professional in software testing, specializing in crafting comprehensive guides to help you master your software testing skills.","url":"https://www.guru99.com/author/thomas","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/thomas-hamilton-author-v2-120x120.png","url":"https://www.guru99.com/images/thomas-hamilton-author-v2-120x120.png","caption":"Thomas Hamilton","inLanguage":"en-US"},"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"Software Testing","headline":"What is Negative Testing? Test cases With Example","description":"NEGATIVE TESTING is a software testing type that checks a system for unexpected input data and conditions. Unexpected conditions can be anything from a wrong data type to a strong hacking attack. The purpose of negative testing is to prevent applications from crashing due to negative inputs.","keywords":"testing","speakable":{"@type":"SpeakableSpecification","cssSelector":[".entry-title",".summary"]},"@type":"Article","author":{"@id":"https://www.guru99.com/author/thomas","name":"Thomas Hamilton"},"dateModified":"2026-07-29T12:26:38+05:30","image":{"@id":"https://www.guru99.com/images/what-is-negative-testing.png"},"copyrightYear":"2026","name":"What is Negative Testing? Test cases With Example","subjectOf":[{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"How does negative testing differ from positive testing?","acceptedAnswer":{"@type":"Answer","text":"Positive testing feeds valid data and confirms the expected result. Negative testing feeds invalid data, wrong formats and broken sequences, and confirms the application rejects them with a controlled message instead of failing."}},{"@type":"Question","name":"What are typical negative test cases for a login form?","acceptedAnswer":{"@type":"Answer","text":"Blank credentials, a valid user with a wrong password, SQL fragments in the username, over-length strings, leading or trailing spaces, disabled accounts, and repeated failed attempts to confirm lockout behaviour works."}},{"@type":"Question","name":"Is negative testing the same as security testing?","acceptedAnswer":{"@type":"Answer","text":"No. They overlap where invalid or hostile input is involved, but security testing also covers authentication, authorisation, encryption and session handling. Negative testing is a broader input and condition technique."}},{"@type":"Question","name":"Who is responsible for writing negative test cases?","acceptedAnswer":{"@type":"Answer","text":"Testers and QA engineers usually write them, often with a developer reviewing error paths and a business analyst confirming which invalid conditions the requirements actually forbid."}},{"@type":"Question","name":"How much negative testing is enough?","acceptedAnswer":{"@type":"Answer","text":"Enough to cover every rejected input class, every boundary and every high-impact failure path. Beyond that, added cases return little value, so risk and impact set the stopping point."}},{"@type":"Question","name":"Can negative testing be automated?","acceptedAnswer":{"@type":"Answer","text":"Yes. Invalid-input cases are highly repeatable, so they suit automation testing and regression suites. Fuzzing tools automate random-input generation, while assertions check that validation messages appear."}},{"@type":"Question","name":"How does AI help create negative test cases?","acceptedAnswer":{"@type":"Answer","text":"Models read requirements or a form schema and propose invalid values, boundary conditions and hostile strings a tester may not list manually. A reviewer still confirms each expected result matches the specification."}},{"@type":"Question","name":"Can GitHub Copilot write negative test scripts?","acceptedAnswer":{"@type":"Answer","text":"Yes, it drafts assertion code, invalid-data fixtures and parameterised cases from an existing test file. The generated expectations need review, because a plausible-looking assertion can encode the wrong behaviour."}}]}],"@id":"https://www.guru99.com/negative-testing.html#schema-1154392","isPartOf":{"@id":"https://www.guru99.com/negative-testing.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/negative-testing.html#webpage"}}]}
```
