Tuesday, October 8, 2019

What are the benefits of unit testing?

Unit testing is a software testing mechanism to determine a unit of code is working correctly and also it enforces to segregate the programming code into a smaller unit and a small unit will be always easy for developer to design, code and test compare to big module.


unit testing life cycle
Unit Testing Life Cycle


There is always a discussion happened in team, why we should spend time to write the unit testing and what’s benefit of having it.

In this article, on basis of my many years’ experience in writing unit test, I will try to explain what’s benefit you will be have to introducing the unit testing into development process.

1.   Better Design:
Before writing of actual code, we should write the unit test, it enforce you to think about the better design and deeply understanding of responsibility of component, which you are going to develop.

2.   Quality of Code
Unit testing improves the quality of the code.  In early phase, it identifies every defect that may have come up before code is sent further for deployment. Unit testing also enforce you to write the more decouple and reusable of code.

3.   Enforce Agile Process:
    It is very risky to change of old design code. In agile process, we should always ready for new requirement or changes in existing requirement and changing in existing and testable design code is very risky but if unit test is proper placed it gives confidence to developer to modify existing design or re-introduce new design.

4.   Reduce of Cost:
if you think in long term of project, unit testing always reduce the project cost, if unit test is written for developed software, the maintenance becomes more easy for developer and he can confidently modified existing code and quickly test modified code with help of unit testing and also for new development, the bugs are found early, unit testing helps reduce the cost of bug fixes. Imagine the cost of a bug found during the later stages of development, like during system testing or during acceptance testing. Of course, bugs detected earlier are easier to fix because bugs detected later are usually the result of many changes, and you don’t really know which one caused the bug.

No comments:

SQL Server - Identify unused indexes

 In this blog, we learn about the index usage information (SYS.DM_DB_INDEX_USAGE_STATS) and analyze the index usage data (USER_SEEKS, USER_S...