QTP tutorials & interview questions


Search more on QTP here

Negative Testing Examples

7 Examples of Negative Test Cases

The process of negative testing is intended to exhibit - that a system does not do what it is not believed or supposed to do. While positive testing verifies that your application works as expected, negative testing makes sure that your application can gracefully handle invalid input or unexpected/ unpredicted user behavior.

Below are some of the examples of negative test cases:
1.
I worked on an application where in there were few modules which had an Attachment tab containing buttons for adding an attachment (DOCX, PDF, and JPEG etc.), viewing an attachment, editing an attachment and deleting an attachment. In this scenario one of the negative test cases was uploading an empty DOCX file. It was uploaded fine but while viewing, it showed exceptions.
2.
Suppose there is a Date field on a page. Negative testing will require you to enter invalid dates. On the other hand there are some fields which are required like Name etc. Try leaving those required fields empty and examine application behavior or response with that. For a Numeric field, try entering alphabets or vice versa to observe application behavior. For a field accepting limited characters observe application behavior by entering more characters than limited, enter negative numbers in case only positive are accepted and so on.
3.
If a feature implements authentication/verification functionality, a positive test would consist of trying the legitimate username and legitimate password. Everything else would be negative testing, including incorrect username, incorrect password, and someone else's password, other special characters (not allowed for username/password) and so on.
4.
Negative test cases for an installer includes - try installing on a drive with “not adequate” disk space, try installing in a “read only” folder/directory etc, consume more RAM so that it starts paging data and see the behavior of installer afterwards.
5.
Negative test cases about ATM (Automated Teller Machine) will include Inserting a wrong ATM card, or wrong pin number, or responding to an ATM query after taking long pause etc.
6.
A compact disk player can be in one of three states: Standby, On or Playing.

When in standby mode, the CD player can be turned On by pressing the standby button once (an indicator light turns from red to green to show the CD player is On). When the CD player is On, it can return to standby mode by pressing the standby button once (an indicator light turns from green to red to show the CD player is in standby mode). When the CD player is On, pressing the play button causes the currently loaded CD to play. Pressing the stop button when the CD player is playing a CD causes the CD player to stop playing the disk.

Examples of positive tests could include:
Verifying that with the CD player in Standby mode, pressing the standby button causes the CD player to turn On and the indicator light changes from red to green.

Verifying that with the CD player in the On state, pressing the Standby button causes the state of the CD player to change to Standby and the indicator light changes from green to red.

Examples of negative tests could include:
Investigating what happens if the CD player is playing a CD and the Standby button is pressed.

Investigating what happens if the CD player is On and the Play button is pressed without CD in the CD player.
[Source of this example: Testing It: An Off-the-Shelf Software Testing Process By John Watkins, Simon Mills]
7.
See how Google Search was broken with negative testing.[Link]