# Negative testing

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Negative_testing
> Markdown URL: https://mediated.wiki/source/Negative_testing.md
> Source: https://en.wikipedia.org/wiki/Negative_testing
> Source revision: 1297022639
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Testing if a system can handle unexpected input

This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages) This article is written like a personal reflection, personal essay, or argumentative essay that states a Wikipedia editor's personal feelings or presents an original argument about a topic. Please help improve it by rewriting it in an encyclopedic style. (January 2017) (Learn how and when to remove this message) This article provides insufficient context for those unfamiliar with the subject. Please help improve the article by providing more context for the reader. (February 2018) (Learn how and when to remove this message) This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. Find sources: "Negative testing" – news · newspapers · books · scholar · JSTOR (January 2021) (Learn how and when to remove this message) (Learn how and when to remove this message)

**Negative testing** is a method of testing an [application](/source/Application_software) or system to improve the likelihood that an application works as intended/specified and can handle unexpected input and user behavior.[1] Invalid data is inserted to compare the output against the given input. Negative testing is also known as failure testing or error path testing. When performing negative testing exceptions are expected. This shows that the application is able to handle improper user behavior. Users input values that do not work in the system to test its ability to handle incorrect values or [system failure](/source/Systems_Failure).

## Purpose

- The purpose of negative testing is to prevent the application from crashing and it also helps improve the quality of an application by detecting defects.

- Negative testing helps you to improve the testing coverage of the application.

- Negative testing makes the application more stable and reliable.

- Negative testing together with positive testing allows users to test the application with any valid (or invalid) [input data](/source/Input_data).

## Benefits of negative testing

Negative testing is done to check that the product deals properly with the circumstance for which it is not programmed. The fundamental aim of this testing is to check how bad data is taken care of by the systems, and appropriate errors are shown to the client when bad data is entered. Both positive and negative testing play an important role. Positive testing ensures that the application does what it is implied for and performs each function as expected. Negative testing is opposite of positive testing. Negative testing discovers diverse approaches to make the [application crash](/source/Crash_(computing)) and handle the crash effortlessly.

**Example**

- If there is a text box that can only take numeric values but the user tries to type a letter, the correct behavior would be to display a message such as "(Incorrect data) Please enter a number".

- If the user is to fill the name field and there are ground rules that the name text is mandatory to fill, but that the name box shouldn't have values other than letters (no numeric values and special characters). Negative test cases could be a name containing numeric values or special characters. The correct behavior of the system would be to not display those invalid characters.

## Parameters for writing Negative test cases

There are two basic techniques that help to write the sufficient test cases to cover most of the functionalities of the system. Both these techniques are used in positive testing as well. The two parameters are:

- **[Boundary-value analysis](/source/Boundary-value_analysis)**

Boundary indicates a limit to something. In this parameter, [test scenarios](/source/Test_scenario) are designed in such a way that it covers the boundary values and validates how the application behaves on these boundary values.

**Example** If there is an application that accepts Ids ranging from 0–255. Hence in this scenario, 0,255 will form the boundary values. The values within the range of 0–255 will constitute the positive testing. Any inputs going below 0 or above 255 will be considered invalid and will constitute negative testing.

- **[Equivalence Partitioning](/source/Equivalence_Partitioning)**

The input data may be divided into many partitions. Values from each partition must be tested at least once. Partitions with valid values are used for positive testing. While partitions with invalid values are used for negative testing.

**Example** Numeric values from minus ten to ten are divided into two partitions: from minus ten to zero and from one to ten. If we need to test positive numeric values, then the first partition (from minus ten to zero) is used in negative testing.

## References

1. **[^](#cite_ref-1)** ["Negative Testing"](https://smartbear.com/learn/automated-testing/negative-testing/). *smartbear.com*. Retrieved 2020-05-22.

v t e Software testing Test levels Acceptance testing System integration testing System testing Integration testing Unit testing Test types, techniques, tactics A/B testing Benchmark Compatibility testing Concolic testing Concurrent testing Conformance testing Continuous testing Destructive testing Development testing Differential testing Dynamic program analysis Installation testing Negative testing Random testing Regression testing Security testing Smoke testing (software) Software performance testing Stress testing Symbolic execution Test automation Usability testing [x]-box style Black-box testing All-pairs testing Exploratory testing Fuzz testing Model-based testing Scenario testing Grey-box testing White-box testing API testing Mutation testing Static testing See also Graphical user interface testing Manual testing Orthogonal array testing Pair testing Soak testing Software reliability testing Stress testing Web testing

---
Adapted from the Wikipedia article [Negative testing](https://en.wikipedia.org/wiki/Negative_testing) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Negative_testing?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
