This type of testing is performed by developers before the setup is handed over to the testing team to formally execute the test cases. Unit testing is performed by the respective developers on the individual units of source code assigned areas. The developers use test data that is different from the test data of the quality assurance team.
The goal of unit testing is to isolate each part of the program and show that individual parts are correct in terms of requirements and functionality.
The advantage of detecting any errors in the software early in the day is that by doing so the team minimizes software development risks, as well as time and money wasted in having to go back and undo fundamental problems in the program once it is nearly completed.
Limitations of Unit Testing
Testing cannot catch each and every bug in an application. It is impossible to evaluate every execution path in every software application.
There is a limit to the number of scenarios and test data that a developer can use to verify a source code. After having exhausted all the options, there is no choice but to stop unit testing and merge the code segment with other units.
Example of Unit testing is explain below
For example you are testing a function; whether a loop or statement in a program is working properly or not then this is called unit testing. A beneficial example of a framework that allows automated unit testing is JUNIT (a unit testing framework for java). XUnitis a more general framework which supports other languages like C#, ASP, C++, Delphi and Python to name a few.
Tests that are performed during the unit testing are explained below
- Module Interface test: In module interface test, it is checked whether the information is properly flowing into the program unit (or module) and properly happening out of it or not.
- Local data structures: These are tested to inquiry if the local data within the module is stored properly or not.
- Boundary conditions: It is observed that much software often fails at boundary related conditions. That’s why boundary related conditions are always tested to make sure that the program is properly working at its boundary conditions.
- Independent paths: All independent paths are tested to see that they are properly executing their task and terminating at the end of the program.
- Error handling paths: These are tested to review if errors are handled properly by them or not.