The primary objective of testing is make the application under test is defect free and make quality application.
Many of us know that there are different types of testing needs to perform to make application defect free like Functional testing, Integration testing, system testing, regression testing, sanity testing, smoke testing, alpha and beta testing, UAT testing etc. If we think deeper then you definitely realize that each testing activity is further divided in to two different categories: Positive testing and negative testing.
In this article we are concentrating on one of the category called Negative testing. Let’s discuss in below section about what is Negative testing, How To Write down Negative Test Cases, Advantages of Negative Test Cases with examples.
When any tester start thinking of testing then every tester first thinking around the positive test cases. It is absolutely necessary to know why Negative testing is essential. The Negative testing is plays an vital role in test case execution.
Negative Testing is a part of testing which tests what an application is not supposed to do i.e. what is not defined in the documents or requirements. The negative testing is always talk about the process of applying creativity as much as possible and validates the inputs with the invalid inputs. The main intention of this testing is check whether bad data how gracefully handled by system and appropriate errors are being displayed to user when bad inputs are entered.
It sometimes also called as Destructive Testing and it is commonly referred to as error path testing or failure testing is generally done to ensure the stability of the application. When it comes to quality of a software application, both positive and negative testing plays equally important roles. By positive testing, we are making sure that application does what it is meant for and performs every function as expected. In negative testing, we find different ways to make the application cry i.e. it crashes and handles that crash in a graceful way. I am not using much technical word here to make you understand the basics of Negative Testing.
For example, if there is a text box which can take only numeric values, enter an alphabet and test it. It should be able to handle that input and throw an expected outcome which could be an error message or a pop up box saying “invalid value entered” etc.
Let’s take one more example to understand negative test scenario related to a music application. Say an application named “Abc” can add up to 100 songs at a time in the playlist, so here 100 is our boundary value and when we enter 101 song to the existing playlist, what would be the outcome? Will that throw an exception? Or a warning message to the user? Or will it restrict user to add more songs? Or will application crash? These were few expected outcomes and reaction of the application to this test scenario will depend on the requirements. Different music applications will have different expected results for the same test case. Stress testing, Load testing and Stability testing are parts of negative testing.
Also read more on => Positive and Negative Testing In Software Testing
How To Write down Negative Test Cases?
In this section, we will see how to write negative test cases with an example. Same rules will apply to any software application. In this example. We have a social media application to test and the requirements are:
- It requires username and password. Password should be alpha numeric and minimum 8 characters long.
- Maximum Limit to add friends to the account is 2000.
- Minimum age to open an account is 18.
Now, for above 3 requirements, let’s make few negative test scenarios.
Test case 1: Enter only numbers in password field.
Test case 2: Enter special characters in password field.
Test case 3: Enter only alphabets in password field.
Test case 4: Enter less than 8 characters in password field.
Test case 5: Try and add more than 2000 people in the friend list. (This can be automated, manually it will take a lot of time)
Test case 6: Enter a birth year which calculates your age in negative.
Test case 7: Enter a birth year which calculates your age in minor category.
These were 7 test scenarios based on 3 given requirements. You can suggest more in the comments section. Point here is to try every input which is invalid and then check the behavior of the app against it. If application crashes or shuts down without any warning or message then it needs to fix and give a proper message or warning, so that user would know what not to do while using the application.
Also read more on => How to Write Good Test Cases?
Advantages of Negative Testing:
Below are 3 major advantages of performing Negative Testing:
- Quality of the application becomes better when negative scenarios are handled properly. If an application handles exceptions in a user friendly way and throws proper warning messages then there are less chances of crashes and quality will become better as well.
- When an application crashes frequently, it is considered unstable. If Negative Testing is applied to it and the load or the root of crash is fixed then application will become stable and pleasant to use.
- User will know the limitations beforehand. As we discussed in previous example where 100 was the limit to the playlist, if user is warned beforehand that application will not add 101 song then he will not try to add more than 100 songs. He will know the limitations of the application and will use it accordingly.
Over to you:
Negative scenarios are based out of the box thinking and has no limitations of how much you can explore. Bugs found during Negative Testing are always crucial since they are found by keeping user in mind. It requires skills and better understanding of the application to test it in a negative way. Tester can also automates negative test case (like the one I mentioned above of adding more than 200 friends to the account) and automation can also be used to load the application with data or to so stress testing on it (an example is monkey testing for mobile devices). When you want a high quality application, both testing should be given equal importance.
If you are not regular reader of this website then highly recommends you to Sign up for our free email newsletter!! Sign up just providing your email address below: