3 ms·
If you have an application that has a lifespan of years, developers will come and go. The unit tests provide some provability that is abstracted from the develo
by locopati 16y ago
If you have an application that has a lifespan of years, developers will come and go. The unit tests provide some provability that is abstracted from the developers.
A developer leaves, they've left behind tests that demonstrate that the code fulfills the requirements and perhaps shows how the code interacts with other areas of code.
A developer arrives, they can see the requirements and how an area of the codebase works by examining unit tests.
Of course, this presumes well-written tests that are actually thorough.
Unit tests also give you a measure of confidence that allows a freer hand when refactoring code. You can change code all you want and if the unit tests still pass, you haven't broken things (again - if the tests do cover all the expectations).
Some level of sanity is required around test-first, test once the code is written, how many tests you need, what level of depth, etc. A one-off app to fulfill a quick-and-dirty need doesn't need as much testing as a core platform that will be running business critical code for years.