Negative testing is used to test how the software performs when it receives incorrect or invalid information. In contrast, positive testing aims to make sure that the software produces the correct functions when it receives valid input.
What Is Negative Testing?
To deliver a quality software product to a client, you need to make sure that you have checked all the possible input parameters. The software that you deliver should function as expected.
This means that the software should perform the correct functions when you perform an action or input information. It also needs to give the correct response when someone enters incorrect information.
For this reason, it is important to consider doing negative testing.
Negative testing takes a different approach than positive testing. Negative testing helps to ensure that you consider all scenarios. It is highly unlikely that the software will only ever receive valid input. This is because it is very easy to make a mistake, mistype something, or fill in the wrong field due to human error.
It is also important to test what happens when someone inputs incorrect data. This is important for security reasons and to prevent any malicious and costly data breaches. In other words, while it is critical to make sure that a software program runs effectively, you also need to think about all of the parameters and consider what could go wrong.
Thus, negative testing seeks to test out all the various data inputs that could be entered incorrectly. Developers then use this process to design adequate responses to this invalid information. These responses could include error messages, failure to submit any data, and/ or proceed to the next stage of the data entry process.
Examples Of Negative Testing
To demonstrate what negative testing is, we can use the example of entering a mandatory name value into an online entry field.
If you enter invalid data, like a string of numbers instead of letters, the program needs to give an appropriate response. This would be to alert the user in a certain way. For example, it might show an alert message in red text and not proceed to the next function.
Another example is testing incorrect data input into a field that requires a specific form of data entry. This could include placing a non-existent date into a data entry field, or the age 200 into an entry form.
Thus, negative testing seeks to think about what could be entered incorrectly. This helps to ensure that the software can respond appropriately to any invalid information.
As we touched on above, it is important to have an understanding of what parameters can be considered negative before you can carry out negative testing.
To make things easier, negative testing parameters can include a range of negative inputs grouped. This makes testing quicker and more efficient. Looking back to the name entry example, incorrect data could, therefore, include data like numbers, an empty field, special characters, and too many letters.
Negative Test Case Parameters
When building a simple software application, establishing the range of incorrect inputs might be more straightforward. However, with a large scale application, it can be easier to use the following tools to find negative testing parameters.
1. Boundary Value Analysis
In the case of boundary value analysis, you consider that data is incorrect if it falls outside of a specific boundary range. Thus, you can use this data for negative testing.
As discussed above, when inserting data about age, any number beyond a reasonable life expectancy may be a negative input. So, any number higher than 100 is considered beyond the boundary and is, therefore, an invalid input. You can then use this range of inputs when designing your negative testing strategy.
2. Equivalence Partitioning
Equivalence partitioning also divides valid and invalid data into separate partitions according to a range of values.
Following on from the example in the previous point, on a linear chart, all of the numbers from 1 – 100 would be partitioned into valid data classes. You would then consider all numbers above 100 as invalid data classes.
Essentially, both of these tools involve mapping out the relevant parameters along positive and negative axes. This allows you to cover a broader scope of possibilities when developing your testing strategy.
How To Do Negative Testing?
All of the above points give a fair indication of how to start thinking about writing negative test cases. However, it is really important to take the time to sit down and think about all the possible scenarios that could affect your application negatively before doing so.
Of course, negative testing also needs to factor in budget considerations. So, while you could explore infinite possibilities, you do need to prioritize certain testing parameters upfront. This will ensure that you don’t waste any time or money.
Thus, designing an adequate test case includes testing any kind of data input that could potentially cause your application to crash. This is exactly what you don’t want to happen when a client uses your finished product. You’ll also want to cover all of the potential security pitfalls that could occur when establishing the priorities of your test case.
It is also helpful to think about all of the unexpected data that one could enter into the program. These include simple mistakes that might have been overlooked, but which could lead to frustration for users.
After reading this article, you now know the difference between positive and negative testing. You should also have a good idea of what negative testing is. We have also given some examples of negative testing, some tools to establish parameters, and how to think about designing your first negative test case.
Join 60,000+ Subscribers
For latest blogs, industry updates and exclusive tips.
*Your email is safe with us, we also hate spam