Negative Testing

In software testing, the following are the main testing strategies-

  • Positive Testing – Positive testing is also known as “Happy Path Testing”. In this testing strategy, by proving valid and correct data, the system’s behavior is checked. Any error or unexpected result is not desired in this testing strategy.
  • Negative Testing – Negative testing makes sure the system works smoothly when an invalid or unexpected data is entered. It is also known as “An error Path Testing” or “Failure Testing”. Exceptions or errors are desired in this testing strategy.

In this tutorial, we will focus on “Negative Testing”.

What is Negative Testing?

While using any application, it is quite possible that the user may enter invalid data intentionally or unintentionally. Now the system should be smart enough to manage such scenarios. More importantly, the system should not crash in the event of such mistakes. 

Negative testing is a type of testing in which a tester intentionally enters invalid data in the system to check the robustness of the application.

When the wrong input is fed to the system, it should show an error message and handle such invalid values gracefully.

One of the best examples of negative testing is the testing of the “Contact number” field. “Contact number” field should not accept anything other than numbers. So, while doing negative testing, a tester will try to enter the alphabets or special characters in the ‘Contact number’ field and will check the system’s behavior. The system should display an error message such as “Invalid Value. This field accepts only numbers”.

Negative testing can be done using both manual and automation testing. Negative testing is also useful while doing security checks of the system. A malicious user deliberately tries to hack the system and exploit vulnerabilities by passing some scripts or commands in the text fields. A thoroughly negative tested application can help in minimizing the risk for the same.

Some Examples of Negative Testing

This section lists some scenarios of negative test cases-

  • Check Field Size – Some fields have a predefined field size limit. For example, the contact number field cannot have more or less than 10 digits. To test such a scenario, testers will try entering more than or less than the required number of characters or digits and see whether the system shows an error message or whether the system lets the user enter extra digits or characters.
  • Check Data Type – All the fields in an application have a predefined data type assigned to them. For example, the ‘Photo’ field might accept only files with .jpg or .png extensions. In such cases, testers will try entering invalid extension files or invalid data. In the example of the ‘Photo’ field, testers might try uploading files with .pdf or .docs extensions. Once invalid data is entered, an error message should be displayed.

Two Basic Techniques of Negative Testing

During the testing process of any application, for both negative or positive testing strategies, exhausting testing with all the test data might not be possible as it might become time and resource consuming.

Negative testing usually has a lower priority than positive testing. Thus, if the project is delayed and the testing team has less time to complete negative testing, there are some techniques that do not use all the available test data but choose the best test data that will cover all the possible test scenarios.

Following are such two techniques that are used to perform negative testing-

1. Equivalence Partitioning

It is also known as Equivalence Class Partitioning (ECP) and is a black box technique. In this technique, test data is divided into equivalent classes or partition and based on these partitions, test cases are designed. These test cases will cover at least one value from each partition.

Let’s take an example to understand this technique.

Suppose there is an e-commerce site that has the ‘Select Quantity’ field for some makeup item. Now, the requirement is such that any customer or user cannot order more than 5 items at once. This means values 0 to 5 are valid and values less than 0 and greater than 5 are invalid.

For this example, we can divide test data into the following partitions:

Partition A Partition B Partition C
Less than 00 to 5Greater than 5

Here, any value of partition A and C are invalid. Any value of partition B is valid. These partitions are equivalent classes. So, while testing, we can choose any one value from each partition and run a test case for the same. We do not need to check for all the values of each partition. 

We can safely assume that if we check only one value from the partition with a valid value, it will give the same result if we check for other values of the same partition. The same assumption applies to the partition with invalid values.

Now, in our example,

Partition A – If we test for value -1 or any value less than 0 and an error message is displayed, that means this test case will give the same results for other values of this partition.

Partition B – This class is for valid values. So, if we test for value 2 and the system accepts the value, we can assume that the system will accept any value between 0 and 5.

Partition C – If we test for value 6 or 100 and an error message is displayed, we can assume that the system will perform in a similar manner for other values of this partition.

For negative testing, any values picked from Partition A and C’s values will be considered.

2. Boundary Value Analysis (BVA)

Boundary value analysis is again a black box technique. Here, as explained in ‘Equivalence Partitioning’, after dividing test data into equivalent classes, only the boundary values of these partitions are checked.

Let’s take the same example of the “Item Quantity” field, the values lying the boundary of the partition will be-

Partition A Partition B Partition C
-10, 56

For negative testing, boundary values falling within Partition A and C will be considered i.e. -1 and 6.


Negative testing is useful in making the system more robust and accurate. It helps the testing team in covering all the possible scenarios which can affect the functioning of the system negatively. 

Negative testing has its own disadvantages too. Apart from being a time-consuming exercise, it also increases workload as it needs extra thinking when it comes to test case creation. But if the application needs to be completely error-free, negative testing is equally important as positive testing.

That’s it for this tutorial, we hope that you were able to learn the concept of ‘Negative Testing’ in detail.

2 thoughts on “Negative Testing”

  1. I am not agreeing with this. You mentioned negative test data. Not negative scenario.
    If we use negatives test data then system will display messages which is already mentioned in requirement so infact we are validating the same messages with negative test data- and this is called happy path testing.


Leave a Comment