Negative Testing

This Article is on Negative Testing, I will try to explain here all about Negative Testing with some practical examples and sample test cases.Negative testing means testing the application for those condition for which application not meant to be. Like if there is a name text field and that text field should only accept the character as per the requirement then negative testing for this requirement would be entering the digit, special symbols etc.detail negative test cases are given down the article.

We have number of testing types like functional testing, integration testing, smoke & sanity and many more, while writing the test cases for mentioned testing type we need to consider both positive as well as negative aspect of the testing for Application.

So what is the main difference between the positive and negative testing? The answer of this is positive testing means testing the application for positive flow, expected flow, lets take the above mentioned requirement if the requirement is that the name text field only accept the char then positive testing would be entering only character and the negative testing for the same requirement would be entering digit , special symbol, keep it blank etc. I hope you got the difference between both the testing if not by looking below mentioned example you will get better idea..

If we perform only positive testing and application may found working as expected then still why do we need to perform negative testing? Many of you might have this question. Consider a scenario where we launched our application in the market. And a new user visited our site and start registering in our application and there is a mobile number field which is designed to accept only 10 digit but user does not know this so he may enter number like +91-9185205xxx this ,so he may get following shown error.this error page came because user entered + and - which is not allowed as it is symbols not digits. To make sure that our application is capable to handle unexpected data and unaccepted steps properly we need to perform negative testing, moreover this following error page exposes many details which may be useful for hacker to hack the site.

Negative testing also helpful to prevent such a hack attempt on the application.

Error on Negative testing

Let take some practical examples after looking below given example you all will be able to write the negative test cases.

Example 1: Mobile Number Field. 

Negative testing on mobile number field

Requirements :
  • Mobile Number filed should only accept 10 digits.
  • Mobile Number field is mandatory.
Positive and Negative test cases would be as shown follow.

Positive Test Cases :
  • Check the response of the system when user enters 10 digits.

Negative Test Cases :
  • Check the response when we enter 9 digits.
  • Check the response when we enter 11 digits.
  • Check the response when we enter character in it.
  • Check the response when we enter special symbol.
  • Check the response when we keep mobile number field empty and click on save button.
  • Check the response when we enter ten zeros.

These kind of Negative Test Cases you can write. Requirements plays an important role to write positive as well as negative test cases. So try to understand requirement in depth first.

Example 2 : Email Id field.

Negative testing on email field

Requirements :
  • Email id field should be mandatory.
  • Email id field should accept valid format (e.g. xxx@domain.com).
  • Email id field should accept email id with sub-domain (xxx@subdomain.domain.com).
  • Email id field should allow email id with dot and , dash(e.g xxx_xxx@Domain.com).
  • Email id with char and digit should be allowed.
  • Email id with any extension should be allowed.(e.g xxx@domain.extension) Etc.
Positive Test Cases :
  • Check the response when we enters “xxx@domain.com”.
  • Check the response when we enters “xxx.xxx@domain.com”
  • Check the response when we enters “xxx@subdomain.domain.com”
  • Check the response when we enters “xxx@domain.org”
  • Check the response when we enters “xxx@domain.co.in”
  • Check the response when we enters “xxx@domain.party”
  • Check the response when we enters “xxx@domain.science”
  • Check the response when we enters “xxx@domain.party”
  • Check the response when we enters “xxx-vvv@domain.com”
  • Check the response when we enters “123456789@domain.com”
You can write many more test cases.

Negative Test Cases :
  • Check the response when we enters “.xxx@domain.com”.
  • Check the response when we enters “xxx@4444.55555”. 
  • Check the response when we enters “xxx@domain…com”.
  • Check the response when we enters “xx@#$$%%^^:”{}/?><x@domain.com”.
  • Check the response when we enters “xxx@--domain.com”.
  • Check the response when we enters “..xxx@domain.com”.
  • Check the response when we enters “うえ@domain.com”.
  • Check the response when we enters “@domain.com”.
  • Check the response when we enters “xxx@domain”
  • Check the response when we enters “ddd@xxx@domain”
There kind of negative test cases you can write To evaluate email address field.

No comments:

Post a Comment