Unit testing is a level of software testing and software development process which test source code of individual unit or module of software product. Unit testing test as smallest testable part of an application.
Primary goal of unit testing is to take the smallest isolated piece of software application and check whether they behave exactly what user want.
After isolation of software application stub, driver and mock object is used to test by unit testing.
It is used to validate each unit or component of the software perform as designed.
All modules are tested individually and find out the errors before integrating all modules to improve quality software application.
It reduces errors and enhances test coverage by testing each unit of software application.
It tests “Is the error due to defect in units.”
It is first level of testing and done prior integration testing.
It follows white box testing.
It is tested by developer itself or sometimes independent testers.
Unit testing done by automated or manually.
It is also called as module testing or component testing.
Benefits of unit testing -:
– Errors are found in early stage of software development process
– Debugging is easy
– Codes are more reusable
– Reduces the test cases
Example of unit testing -:
Suppose online railway reservation system has different modules like login, plan my journey, cancel ticket, refund and print ticket. In unit testing test all modules separately and check behavior of modules. It focuses on single component or modules of railway reservation system.