Unit testing is the first level of testing performed on individual modules, components or piece of code. In unit testing the individual modules are tested as independent components to ensure that they work correctly and are fit to be assembled/integrated with other components. This testing is performed by developers. The developers usually write unit tests for the piece of code written by them.
Unit testing cannot be performed manually. The unit tests are always automated and more specifically use White-box testing technique as the knowledge of the piece of code and internal architecture is required to test the code.
Unit testing cannot be performed manually. The unit tests are always automated and more specifically use White-box testing technique as the knowledge of the piece of code and internal architecture is required to test the code.
Advantages of Unit Testing
- Defects within a module can be detected at earlier stages of development. Hence the cost of fixing the defects greatly reduces.
- Unit testing improves testing efficiency and better resource utilisation as testing of a module can be started without having to wait for other modules to finish.
- Exhaustive testing focusing on individual functionality is possible in unit testing.
- Unit tests aid in faster development and debugging as the impact of new changes can be easily detected by running the unit tests.
- Successful unit test report generates a sense of confidence about the quality of code. Modules successfully unit tested can be easily merged with other modules.
Limitations of Unit Testing
- Unit testing cannot detect integration or interfacing issues between two modules.
- It cannot catch complex errors in the system ranging multiple modules.
- It cannot test non-functional attributes like usability, scalability, overall performance of the system etc.
- Unit tests cannot guarantee functional correctness or conformance of application with its business requirements.