Positive Testing and Negative Testing
Example of Positive and Negative testing
Example 1
Let’s see our first example
Let’s assume that we have a field in a website that accepts
- numbers only
- numbers range between 0 to 9
So, If we write test cases using Test Case Design Technique, then we can use 2 Techniques
- Boundary Value Analysis
- Equivalence class Partitioning
As per Boundary Value Analysis, There will be 6 Test Cases will come up
- -1 should be not allowed – Negative Testing
- 0 should be allowed – Positive Testing
- 1 should be allowed – Positive Testing
- 8 should be allowed – Positive Testing
- 9 should be allowed – Positive Testing
- 10 should be not allowed – Negative Testing
As per Equivalence class Partitioning, 3 Test Cases will come up
- Any value less then 0 – (-5) – should be not allowed – Negative Testing
- Any value between 0 to 9 – (4) – should be allowed – Positive Testing
- Any value more then 9 – (16) – should be not allowed – Negative Testing
So, We have seen in the above, what is negative test case and what is a positive test case.
Example 2
Let’s take 1 more example to understand positive testing and negative testing.
Let’s take an example of login functionality.
If we want to test login functionality of any application, then we will have to use Decision Table Testing Technique while writing test cases.
As per Decision Table Testing Technique, We are going to get below test cases.
Test Cases | Test Case 1 | Test Case 2 | Test Case 3 | Test Case 4 |
---|---|---|---|---|
User name | True | False | True | False |
Password | True | True | False | False |
Login | Successful | Failed | Failed | Failed |
Type of Testing | Positive Testing | Negative Testing | Negative Testing | Negative Testing |
So, this is how we perform positive testing and negative testing in case of login functionality.
Now, If we want to define positive testing and negative testing, then it would be
What is Positive and Negative testing
What is Positive Testing
When we perform testing on a software application with valid input data, then this type of testing is called Positive testing.
What is Negative Testing
When we perform testing on a software application with invalid input data, then this type of testing is called Negative testing.
Importance of Positive Testing and Negative Testing
Positive and Negative Testing is very important due to below reasons
- System should work as expected – Positive and Negative Testing is done so that we can find out that the system is actually doing what it is expected to do. We should be able to login when we provide correct credentials and we should not be able to login when we provide wrong credentials.
- Security Purpose – We have seen in the login example, that no one should be able to login for wrong credentials, So if we don’t do negative testing, and anyone is able to access our account with wrong password, then our account will no longer be secure.
- Stability of the System – We have seen in the above examples that if a field accepts number between 0 to 9, then rest of the numbers should not be allowed, but if we don’t do negative testing and the field accepts all the number, then our system might crash, as the system capacity would be design in order to accept only numbers between 0 to 9 but now it is accepting all the numbers.
Summary
We have covered below topics in this session.
- Positive Testing and Negative Testing
- Example of Positive and Negative testing
- What is Positive and Negative testing
- What is Positive Testing
- What is Negative Testing
- Importance of Positive Testing and Negative testing
Question
Give an example of Negative Testing from eCommerce Application.