The unit test method has already become a standard for a project of high quality. However, the importance of unit testing is still often underestimated. Being eager to speed-up a project and reduce money and time for software development, customers often try to get rid of unit testing in the project as they do not understand its benefits.
Developers will agree that it is usually a problem to convince management of the project or the customer that unit testing is also an essential part of the software development. Of course you may think that it is enough to rely on the manual testing of a QA department or convince yourself that the skills of developers are strong enough not to warrant the unit tests, which may seem like an outdated activity.
WHAT ARE UNIT TESTS?
Unit tests help determine if the isolated modules of software work correctly. After separate functionalities or modules are verified, parts of the software can be merged together and tested as a whole (Integration Testing and System Testing).
Unit testing (usually automated) makes a basis for a popular software development approach known as Test Driven Development (TDD) that implies first writing tests, then on the basis of these tests creating a code to pass the tests, and then refactoring the code to acceptable standards. Not every team uses TDD in its classic way. Each team or individual developers adapt different technics to the realities of their projects.
WHY YOU MAY WANT TO DO UNIT TESTING?
There are several reasons why doing unit tests is recommended:
1. Bugs preventing. Unit testing helps developers make refactoring and regression easier (?) when new functionalities are added in the future. You can just write a test once you find a bug and prevent that bug from re-appearing in the future.
2. Documentation. Unit tests can be used as the documentation for code, which is extremely important for big projects. If a new developer starts working on the product, unit tests written by his/her predecessor will be very helpful for the developer to get through and understand the existing code.
3. Clarification of specs. Unit tests let you foresee in advance the testability of the functionality, find some gaps in the specification, and ask a Product Owner questions before the development starts.
4. Time saving. Unit testing helps a QA team (or developers) to start testing separate functionalities (modules) without waiting when all of them are developed and integrated.
5. Money saving. The earlier you start testing, the more money you save. Mistakes not discovered early become more expensive as the project comes closer to the release.
TO WRITE OR NOT TO WRITE THE UNIT TESTS?
During the past decade, teams have been using unit testing in various projects in different ways. Time dedicated to writing unit tests prevents and eliminates many troubles. And from my own experience and experience of my colleagues, we can say that each hour spent on unit testing saves ten hours of troubleshooting later in a project. Usually critical errors occur in a project at the worst possible moment, when you are not expecting them at all. It is good if the problem is identified at the beginning of a project when it is easy to fix it. The defects found in the late stages of a project are expensive and put a project at risk of delay.
Having unit tests will not solve all your problems but at least it will save the project from serious rollbacks because of the undiscovered defects.
SVITLA SYSTEMS EXPERIENCE
We use Unit Testing in many projects: Ingenico, Ancestry, Ooma, to name a few. Test coverage in server-side API allows systematizing all functions and fine-tuning work of many components. Tests on mobile (Android) part of the project allow to identify all errors in reporting API, ensuring smooth operation of the respective functionality. Using unit tests on the server and on the client side provide a great set of regression in testing and help to identify and localize errors much faster, while supporting the project in a consistent state.
To read more about unit testing, check this article.
January 20, 2016