What is unit testing?

Unit testing is a process of testing single unit of an application independently. Unit testing involves testing of smallest units of source code to determine they are working properly and are fit for the purpose. Unit testing comes under white box testing and is done by developers. In unit testing test conditions are generated and executed by developers to check developed code meets its requirement and design.
Unit testing is done before integration testing. While testing developers pass a set of input values and checks for the expected result, if result is not as expected then this encourages developers to modify the source code without worrying much about how such changes might affect the functioning of other units or the program as a whole. Developers write tests for every class they produce.


software testing levels


The objective of Unit testing is to test not only the functionality of code, but also to ensure that the code is structurally sound and robust, and able to respond appropriately in all conditions.
It is typically used to verify control flow and data flow, memory leak problems.

Who Does? (Role and Responsibilities):-

Developer Does unit testing.

Technique Used:-

White box technique is used for unit testing.

Types of Defects:-

In unit test generally logical defects, control flow defects and coverage defects are found.

Test Basis:-

For testing low level document (LLD) or code is used.


In unit testing all code review defects are fixed.

Exit Criteria:-

1. When all defects in unit testing are fixed (as per given criteria).
2. When code coverage is achieved.


Drivers, stubs, coverage and unit testing tools.

Output Documents:-

1. Unit testing logs (UTI)
2. Unit test report (UTR)


1. Codes are more reusable. In order to perform unit testing piece of code is considered as single module so this code can be reused gracefully.
2. In unit testing defects are detected at early stage so the cost of fixing the defects is also less ultimately reducing the cost of developing the software or application.
3. In unit testing debugging is very easy, if a defect is caught or a test fails then only latest then only the latest changes need to be debugged.
4. Unit Tests provide a safety net of regression tests and validation tests so that you can integrate effectively.

1. Unit testing can be time-consuming and tedious. Every time when a piece of code is written it needs to get tested and during initial round of testing there is a possibility of having many error so lot of time is wasted in debugging and fixing them.

2. In case of unit testing lot of documentation needs to be maintained. Documentation like module number and its corresponding test record pass or fail.

Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *