What is Unit Testing?
Unit testing is a testing technique wherein individual components are checked by the developer to see if there is any bug in the code. It is to check individual features’ functionality.
This testing is carried out during the development of an application. An individual feature may be either an individual function or a method. This Testing is typically performed by the developer.
In SDLC, this Testing is the First Level of testing before integration Testing.
The objective :
- To isolate a code segment.
- To ensure that the code is correct.
- To thoroughly test each function and method.
- To save the cost of bugs by fixing bugs in the early phases of the development cycle.
- Assisting developers in comprehending the code base and allowing them to make modifications rapidly.
- To aid with code reuse.
Level of Testing:
Types:
- Manual: In this, we execute tests Manually without any tool.
- Automated: In this , we use automation tools for execution.
Unit Testing Techniques:
This testing utilizes white box testing techniques as its focus is on testing the code of the application.
- Data flow Testing
- Control Flow Testing
- Branch Coverage Testing
- Statement Coverage Testing
- Decision Coverage Testing
Process :
Benefit :
- Reduces Defects in the Newly created functionality or reduces bugs when changing the existing feature.
- The cost of testing is less as bugs are identified in the early stage.
- Enhances code restructuring and improves the design.
- Using unit tests in conjunction with the build process improves the quality of the build.
Limitations of Unit Testing:
- As it only operates on code units, it is unable to detect integration or broad-level errors.
- As unit testing does not allow the testing of all execution pathways, it is unable to catch every error in a program.
- It works best when combined with other testing activities.
Unit Testing Tools:
Below are some of the Unit Testing tools:
1. Jtest
2. Junit
3. NUnit
4. EMMA
5. PHPUnit
One Reply to “Keys to Successful Unit Testing”