Negative testing
Template:New unreviewed article
Negative Testing
Introduction
Negative testing ensures that the plot of the application is according to the requirements and can handle the unwanted input and user behavior. Negative testing is the process of applying as much creativity as possible and validating the application against invalid data. In negative testing we put invalid data and see the output. The application determines that the application is not doing anything that is shouldn’t supposed to do. Negative testing is also known as failure testing or error path testing. When performing negative testing exceptions are expected. This shows that your application is able to handle improper user behavior.
Purpose
- The purpose of negative testing is to prevent your application from crashing and it also helps you to improve the quality of your application as it helps you find the defects.
- Negative testing helps you to improve the testing coverage of your application.
- Negative testing makes your application more stable and reliable.
- Negative testing together with positive testing allows you to test your application with any (valid or invalid) input data.
Why negative testing is necessary?
Negative testing is done to check that product deals properly with the circumstance for which it is not programmed. The fundamental aim of this testing is check that how bad data is taken care of by the systems and appropriate errors are being shown to client when bad data(inputs is entered. Both positive and negative plays important role. In Positive testing we are ensuring that application does what it is implied for and perform each function as expected. Negative testing is opposite of positive testing. In negative testing we find diverse approaches to make the application cry i.e. it crashes and handles that crash effortlessly.
Example
- If there is a text box that can only take numeric values but the user type to write letter, the correct behavior in this case “(Incorrect data) Please enter a number” message should be displayed to the user.
- If user is to fill the name field we have decided some ground rules that name text is mandatory to fill , name box shouldn’t have values other then alphabets (no numeric values and special characters).Negative test cases for the text would be Name having numeric values , name having special characters and nothing is written in that text field.
Parameters for writing Negative test cases
There are two basic techniques that help to write the sufficient test cases to cover the most of the functionalities of the system. Both these techniques are used in positive testing as well.
The two parameters are:
* Boundary values analysis
Boundary indicates limit to something. In this parameter we design test scenarios in such a way that it covers the boundary values and validate how application behaves on these boundary values. When the values are within the boundary then it is considered to be positive testing and the inputs that are beyond the boundary values are considered to be a part of negative testing.
Example
If we have application that accepts Ids ranging from 0-255.Hence in this scenario 0,255 will from the boundary values. The values within the range of 0-255 will constitute the positive testing. Any inputs going below from 0 and input going above from 255 will be considered invalid and will constitute negative testing.
* Equivalence Class Partitioning
In equivalence class partitioning we divide the test data into various partitions. These partitions are referred to as equivalence class data. It is assumed that the various input data (data can be a condition) in each partition behave the same way. Hence only one particular condition or situation needs to be tested from each partition, as if one works then all the others in that partition is assumed to work. Similarly if one condition in a partition doesn’t work, then none of the others will work.
Example
In the same example above, the values can be divided into say two partitions. So the two partitions here would be:
- Values -255 to -1 in one partition
- Values 0 to 255 in another partition
Typical negative test case scenarios
In different scenarios negative testing is aimed to find the causes that can result in software/application crash. Some example of these scenarios is given below.
* Populating Required field
Some applications have some mandatory fields that are necessary to fill. To check an applications behavior create a test case that allows the field to stay empty and analyze the response of the tested application.
* Correspondence between data and field types
Dialog boxes and forms contain controls that can accept data of a specific type (for example, numeric, date, text, etc.). To verify whether the application functions properly, you can create a test that enters incorrect data into a control.
* Allowed number of characters
Some applications and web pages have fields that restrict the numbers of characters to be entered for example the value of user name field can contain less than 50 characters. To verify the behavior of the application you can create a test that enters more characters in the field than expected.
* Allowed data bounds and limits
Applications can use input fields that accept data in a certain range. For example, there can be an edit box into which you enter an integer number from 10 to 50, or an edit box that accepts text of a specific length. To check the application’s behavior, create a negative test that enters a value smaller than the lower bound or greater than the upper bound of the specified field.
* Reasonable data
Some applications and web pages include fields that have a reasonable limit, for example, entering 200 or a negative number as the value for the “Your age:” field is not allowed. To check the application's behavior, create a negative test that enters invalid data into the specified field.
* Web Session testing
Some web browsers require that you log in before the first web page is opened. To check that these browsers' function correctly, create a test that tries to open web pages in the tested application without logging in.
Conclusion
Negative test improves the test coverage and make your application more stable and reliable. Positive and negative testing when implemented together allows you to test your application with any possible input (valid and invalid). While positive testing ensures that the business use case is validated, negative testing ensures that the delivered software has no flaws that can be a deterrent in its usage by the customer.