Skip to content
Related Articles

Related Articles

Unit Testing | Software Testing

Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 07 Jun, 2022
Improve Article
Save Article

Prerequisite – Types of Software Testing Unit Testing is a software testing technique by means of which individual units of software i.e. group of computer program modules, usage procedures, and operating procedures are tested to determine whether they are suitable for use or not. It is a testing method using which every independent module is tested to determine if there is an issue by the developer himself. It is correlated with the functional correctness of the independent modules. Unit Testing is defined as a type of software testing where individual components of a software are tested. Unit Testing of the software product is carried out during the development of an application. An individual component may be either an individual function or a procedure. Unit Testing is typically performed by the developer. In SDLC or V Model, Unit testing is the first level of testing done before integration testing. Unit testing is such a type of testing technique that is usually performed by developers. Although due to the reluctance of developers to test, quality assurance engineers also do unit testing. 

Objective of Unit Testing: 

The objective of Unit Testing is:

  1. To isolate a section of code.
  2. To verify the correctness of the code.
  3. To test every function and procedure.
  4. To fix bugs early in the development cycle and to save costs.
  5. To help the developers to understand the code base and enable them to make changes quickly.
  6. To help with code reuse.


Types of Unit Testing: 

There are 2 types of Unit Testing: Manual, and Automated.

Workflow of Unit Testing: Unit Testing Techniques:

 There are 3 types of Unit Testing Techniques. They are

  1. Black Box Testing: This testing technique is used in covering the unit tests for input, user interface, and output parts.
  2. White Box Testing: This technique is used in testing the functional behavior of the system by giving the input and checking the functionality output including the internal design structure and code of the modules.
  3. Gray Box Testing: This technique is used in executing the relevant test cases, test methods, test functions, and analyzing the code performance for the modules.

Unit Testing Tools: 

Here are some commonly used Unit Testing tools: 

  1. Jtest 
  2. Junit 
  3. NUnit 
  4. EMMA
  5. PHPUnit 

Advantages of Unit Testing:

  1. Unit Testing allows developers to learn what functionality is provided by a unit and how to use it to gain a basic understanding of the unit API.
  2. Unit testing allows the programmer to refine code and make sure the module works properly.
  3. Unit testing enables testing parts of the project without waiting for others to be completed.

Disadvantages of Unit Testing:

  1. The process is time-consuming for writing the unit test cases.
  2. Unit Testing will not cover all the errors in the module because there is a chance of having errors in the modules while doing integration testing.
  3. Unit Testing is not efficient for checking the errors in the UI(User Interface) part of the module.
  4. It requires more time for maintenance when the source code is changed frequently.
  5. It cannot cover the non-functional testing parameters such as scalability, the performance of the system, etc.
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!