Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

software testing

What is negative testing in software testing?

Hammad Nasir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

Software testing is an essential part of the Software Development Life Cycle (SDLC) to ensure the quality of a software product. Out of the several software testing techniques employed, in this shot we will discuss the negative testing technique.

Definition

The negative testing technique is used to certify that software doesn’t fail or emit abnormal behavior when invalid input is provided, as displayed in the image below:

Process

  • Make a series of negative test cases.
  • Test the cases and list the results.

The following table lists the usual negative test case categories and their examples:

Test case categories Description Example
Required Field Test All required fields of the form must be filled before submitting. Consider a web application that has several required fields on a form. A good negative test case would be to try submitting the form with an unfilled required field.
Data & Field Correspondence Test Required data type and the data type of the data in the field must match. Consider a text field intended for storing a phone number. A good negative test case would be to try entering non-numeric characters in the field.
Data Bound Test The size of the data in the field should adhere to the upper and lower bounds. Consider a text field that takes a person’s first name as input. The upper and lower bound of the characters is defined to be 30 and 2 characters, respectively. A good test case would be to enter data that is greater than 30 characters or less than 2 characters.
Numeric Bound Test The numeric input must be in range. Consider a numeric field that must only contain positive integers. A good negative test case would be to enter negative integers.
Reasonable Data Test The input data must be logically reasonable. Consider a field that is used to store a person’s age. Entering 500 as a person’s age is absurd. Therefore, a good negative test case would be to enter an age greater than a specified threshold.
Web Session Test The user must be authenticated before interacting with the data. Consider a web application that requires the user to be logged in to submit some data. A good negative test would be to try submitting the data without logging in.

Advantages

  • Reduces software vulnerabilities considerably.

Disadvantages

  • Time consuming and tedious process.
  • Can lead to excessive negative testing.

RELATED TAGS

software testing

CONTRIBUTOR

Hammad Nasir
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring