Increase your development productivity by TDD
A small story that emphasises the importance of test-driven development.
Whilst the world is transforming towards agile and automation of build, test, and deployment practices, understanding the importance of test-driven development practices is vital for increasing the productivity, quality, and time to market.
There is a common perception among some of the IT developers and key stakeholders that the time spent on writing unit-test cases kill their teams’ productive time. It is a wrong perception. A small story to understand the importance of writing unit test cases.
John, a new joiner in an automobile accessories company; he was assigned a task to prepare bolts to screw a car wheel on his first-day work. On his first-day job, he got all the requirements for preparing the bolts. He prepared the bolt and started driving to the car-assembling arena which was a mile apart to test his bolt. Unfortunately, the bolt did not fit. Next day, he was back to work to fix all the issues in the bolt and started driving again to the car-assembling arena. Again it didn't fit.
So what went wrong with John? John failed to test his developed bolt with sample nuts in his local; instead, he tried to test in the integration environment directly without unit testing. At first, he must have ensured that the developed items are possibly a bolt, secondly, he must have validated the bolt with mock nuts for a perfect fit, and then he must have taken to bolt to the integration area.
The mock nuts are just equivalent to writing unit tests in development. Writing unit test cases for their public methods would ensure the deliverables meets the requirements, quality, code integrity and it also tests all the possible scenarios using code coverage.
![CI/CD pipeline](../img/pipeline.jpg)
Increase in productivity
Writing unit test cases would capture the bugs in their local environment itself. This will avoid a long wait to capture the bugs in higher environments. In DevOps, capturing and fixing the bugs early is the basic principle. The below diagram shows that productivity increases by three folds.
Ensures quality
Quality is the key aspects of any deliverables. Business confidence increases as the quality of the deliverables increases. Quality of the product is measured using code coverage. Higher the code coverage means higher the quality. As a best practice, achieving 80% of code coverage is maximum to maintain good quality.
Reduces time to market
Increase in productivity directly boost the time to market of the product. Finding bugs early speed up the overall productivity, decrease the manual intervention and rapid up the time to market.
Improves agility
Rapidly changing business-needs require an agile-based software development model to visualize the result immediately. To achieve this, the automation of the entire product development is essential. The first step of automation starts from code build and unit test.
Conclusion
A journey of a thousand miles begins with a single step. The first step is writing unit test cases to achieve complete automation.