In this article, we will see what is negative testing with some example negative test scenarios.
The article contains the following sections:
What is Negative Testing with Examples?
From the software testers’ point of view, it is very important to verify that the software performs its basic functions as per the requirements but it is equally important to verify that the software is able to gracefully handle any abnormal situations or invalid input which helps to determine the stability of the software. Negative testing is performed to find a situation where there is the possibility of software to crash.
It is a negative approach, where testers try to design test cases to find the negative aspects of the application and validate against invalid input. Negative testing is also known as Failure testing or error path testing. The application’s functional reliability can be measured only with designed negative scenarios.
Examples of Negative Testing (Negative Testing Scenarios):
Example #1. Testing of a phone number field.
Test cases for negative testing could be input non-numeric values or alphabets in the phone number field, test less than 10 characters, or greater than 10 characters in the phone number field.
Example #2. Testing of age field.
The test case for negative testing could be to input age as the alphabet or negative integer.
Example #3. Testing of the zip code field.
Zipcode format varies in different countries. Negative test cases in such scenarios could be input alphanumeric value for the USA, India, and numeric for Canada, UK. Exceeding the number of characters in the zip code field is also a negative test case.
Example #4. For mandatory fields
Test by skipping the required data entry and try to proceed further.
Example #5. For data bounds and limits
Enter large values to test the size of the fields.
When to perform Negative Testing?
Negative testing is performed while doing functional testing of the build where there are chances of unexpected conditions. It can be performed by professionals.
Techniques Used in Positive Testing
Techniques used for negative testing are:
Boundary Value Analysis:
It is related to the invalid partition in your input test data range. The system should reject the values for invalid inputs. Invalid partition is going to have 2 boundaries – lower and upper boundary. If the input test data range is A-B, negative test cases should be designed for A-1 and B+1.
Example #1: For date field (1-31), invalid partition lower boundary(input 0 in date field) and invalid upper boundary(input 32 in date field) are considered for negative test cases.
Example #2: For username fields having specifications of 6-10 characters, invalid partition lower boundary(5 characters) and invalid partition upper boundary(11 characters) are considered for negative test cases.
Example #3: For floating-point values, let the system accept values from 0.2 to 0.8 with one decimal place. Invalid partition lower boundary(input 0.1) and invalid upper boundary(input 0.9) are considered for negative test cases.
Read more about Boundary Value Analysis Test Case Design Technique here
In this technique, input test data is divided into partitions. For negative testing, if you pick a value from an invalid partition, the system should reject that value.
Example #1: For date fields (1-31), input any invalid value such as 0 and negative integer values, the system should reject the values.
Example #2: For username fields having specifications of 6-10 characters, input any value from invalid partition i.e. 0-5 or 11,12,13… and test the behavior of the system. In this case, the system should reject the values and display an error.
Example #3: For Age fields between 18-80 years except for 60-65 yrs, input any value from invalid partition i.e. 0-17 or 60-65 or 81,82,83… and test the behavior of the system.
Read more about Equivalence Test Case Design Technique here
What is the difference between Positive Testing & Negative Testing
Positive Testing Vs Negative Testing
|Positive Testing||Negative Testing|
|It is performed by passing valid test data||It is performed by passing invalid test data|
|It is performed to verify the known set of Test Conditions||It is performed to break the application with unknown set of Test Conditions|
|It covers only valid cases||It covers all possible cases including invalid cases|
|It takes less time||It takes more time|
|It verifies all the requirements are met||It verifies the work flows which are not mentioned in the requirements|
|It makes sure software is working as expected||It makes sure the software is defect free|