Categories: Software Testing

Positive Testing and Negative Testing

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. -1 should be not allowed – Negative Testing
  2. 0 should be allowed – Positive Testing
  3. 1 should be allowed – Positive Testing
  4. 8 should be allowed – Positive Testing
  5. 9 should be allowed – Positive Testing
  6. 10 should be not allowed – Negative Testing

As per Equivalence class Partitioning, 3 Test Cases will come up

  1. Any value less then 0(-5)should be not allowed – Negative Testing
  2. Any value between 0 to 9(4)should be allowed – Positive Testing
  3. 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 CasesTest Case 1Test Case 2Test Case 3Test Case 4
User nameTrueFalseTrueFalse
PasswordTrueTrueFalseFalse
LoginSuccessfulFailedFailedFailed
Type of TestingPositive TestingNegative TestingNegative TestingNegative 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

  1. 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.
  2. 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.
  3. 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.

  1. Positive Testing and Negative Testing
  2. Example of Positive and Negative testing
  3. What is Positive and Negative testing
  4. What is Positive Testing
  5. What is Negative Testing
  6. Importance of Positive Testing and Negative testing

Question

Give an example of Negative Testing from eCommerce Application.

Admin

Working Professional with more than 12 Years of Experience in Software Testing with Automation and Manual Testing Knowledge.

Recent Posts

Why we can not over ride Constructor

Why we can not over ride a Constructor This is a very important question, that,…

55 years ago

Javascript Tutorial – Arrow Function in Javascript

What is Arrow Function In the last session, We had discussed about Anonymous Function. Anonymous…

55 years ago

Javascript Tutorial – Anonymous Function in Javascript

What is Anonymous Function Anonymous Function is a type of function which has no name…

55 years ago

Javascript Tutorial – Map, Filter and Reduce

What is Map, Reduce and Filter Map Filter and Reduce are higher order methods for…

55 years ago

Javascript Tutorial – Different ways of declaring or defining function in Javascript

9 different ways of declaring or defining a function in Javascript In, one of our…

55 years ago

Javascript Tutorial – Loops with Arrays in Javascript

Loops with Arrays in Javascript In our last session, we had seen, What is Array…

55 years ago