What is Negative Testing and Tips on Writing Negative Test Cases?

The primary objective of testing is make the application under test is defect free and make quality application. Negative Testing is help us to improve the testing quality.

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?

What is Negative Testing?

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:

  1. It requires username and password. Password should be alpha numeric and minimum 8 characters long.
  2. Maximum Limit to add friends to the account is 2000.
  3. 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:

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


⇓ Subscribe Us ⇓


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:


 

Check email in your inbox for confirmation to get latest updates Software Testing for free.


  Happy Testing!!!
 

15 thoughts on “What is Negative Testing and Tips on Writing Negative Test Cases?”

  1. Nice information on Negative testing.
    Peoples generally add positive tesring cases, i liked you shared negative testing cases as well.

    Thanks,
    Smita

    Reply
  2. Hi STC,
    I am working as fresher in one of small scale company located at Pune.
    The information you presented here in such a way that it is easy to understand for fresher like me.

    Initially when I was started carrier the negative testing was my main testing approach to test the application. But nowadays i am first executing the positive cases first then negative cases.

    Which testing apprach should we follow while test case execution?

    Thanks,
    Manu

    Reply
  3. This is really great article. In last month I joined software company where we have all text cases are written. Today my manger ask me to check if all test cases are written or not. So I am confused here how to start checking all test cases against the requirements.

    I really appreciate your help. Thanks in advance.

    -Amit

    Reply
  4. Hi,

    Nice article..

    I am confused between term test plan and test strategy. Could you please help me to understand this testing concept.

    I know little bit about Test Strategy: Its a high level document, which defines the objectives of all test stages and techniques that you apply.

    Thanks in advance.
    -Shri

    Reply
  5. The BEST tips… Thanks a lot for your valuable efforts and teaching style, I really like it.

    Next to softwaretestinghelp.com website I see this website helping tester to learn testing concepts with more detailed level.

    Best,
    -Aadarsh

    Reply
  6. Hi ,
    I had a query.
    What if the only document provided to the tester is only an old user manual, in that case , how to write test cases with full coverage . Here the application is a desktop application and we are being provided with no requirement documents even after lot of requests.

    And also, should all the bugs reported while exploratory testing be written in form of test cases ?

    Reply

Leave a Comment

Share This Post