Why Writing Tests Is Worth It

There are many ways to approach software testing. Many programmers think that writing formal tests is a waste of time, but at Tivix we believe that by writing tests in advance, overall development time is reduced while code quality is increased.

The fundamental advantage of writing formal tests is that they will reduce the number of defects in code. Testing can check edge cases that a programmer may have overlooked in the development phase.

Another advantage is that developers can improve their code without breaking it. They don’t need to test software manually after each small change, so future refactoring or bug fixes are considerably less time-consuming.

Writing tests is also good practice from a business point of view. We all agree that people want to use safe and reliable software. Nowadays, users have high standards for usability, and won’t come back to your application if it didn’t work properly on their first try.
 
I’m aware that these are just empty words and you may be still unconvinced, so let’s look at some numbers. Four people, Nachiappan Nagappan, E. Michael Maximilien, Thirumalesh Bhat and Laurie Williams made an experiment with Test-Driven Development (TDD) on four completely independent highly experienced teams. What they discovered was that the TDD teams made code that was 40-90% better in terms of defect density than non-TDD teams. They also measured that TDD teams were working 15-35% longer to complete their projects than non-TDD teams, so for a 12-month project, TDD can result in 4 months more time spent on development.

The study and its results were published in an article entitled, “Realizing quality improvement through test driven development: results and experiences of four industrial team”
 
The conclusion is very simple: you have to make a decision between a shorter development phase and lower costs, with the possibility of high defect density; and a longer development phase and potentially higher costs, but safer and more reliable software.

Image courtesy of Zurich U.S.