Unit Testing

Introduction

 It is a level of the software testing process where individual units/components of a software/system are tested. The purpose is to validate that each unit of the software performs as designed.

image 30

Unit Testing Benefits

Developers looking to learn what functionality is provided by a unit and how to use it can look at the unit tests to gain a basic understanding of the unit API.

Unit testing allows the programmer to refactor code at a later date, and make sure the module still works correctly (i.e. Regression testing).

The procedure is to write test cases for all functions and methods so that whenever a change causes a fault, it can be quickly identified and fixed.

Due to the modular nature of the unit testing, we can test parts of the project without waiting for others to be completed.

Unit Testing Limitations

Unit testing can’t be expected to catch every error in a program. It is not possible to evaluate all execution paths even in the most trivial programs

Unit testing by its very nature focuses on a unit of code. Hence it can’t catch integration errors or broad system-level errors.