Benefits of Unit Testing

Benefits of Unit Testing

If you are working in regulated industry, a unit testing is a part of the software development process because it usually requires to show V & V(Verification and Validation) in Figure-1.


What is unit testing?

The unit is defined in software development as the smallest peace that can be isolated from other parts of application. So, the unit could be the module as one file or the function. The unit testing is the process to verify each unit of code beaves as expected. I would like to introduce some benefits of unit testing next.

Benefit#1 - Perfect for Agile(early detection of bugs)


Agile is the process for a small software development cycle in short term of time and repeat until product development ends. Typically, implementing few features is the goal during the one cycle. Recently, Agile is more preferred approach in software world rather than water-fall approach because it reduces the cost and effort of fixing bugs later in the process. As you seen above Figure-2, after develop your production code, you need to test. How are you going to test what you developed. Writing unit test is easy and it can verify each unit of code behaves as expected.

Benefit#2 - Clean code(facilitates refactoring)

Developer can confidently refactor the code to more readable or more efficient with existing unit test cases. Those test cases can be used as regressions and refactoring code should not affect the existing functionality. By doing this activity, code quality would be also improved.

Benefit#3 - Documentation and Specification

Unit test cases can be a living documentation where new developers can understand what this module is doing easily. Also, they can have a traceability to design specification which is written based on software requirements. Providing traceability is the key to demonstrates V & V(Verification and Validation).

Did you find this article valuable?

Support Hyunwoo Choi by becoming a sponsor. Any amount is appreciated!