3 ms·
Thorough unit tests are required for code that is open to unforeseeable new uses. The existing application may not provide enough coverage. Unit tests can exerc
by kazinator 6y ago
Thorough unit tests are required for code that is open to unforeseeable new uses. The existing application may not provide enough coverage. Unit tests can exercise all the requirements of a module that are not yet being used now so that in the future, someone can do new things with that module without having to fix it first (thereby risking the existing application).
The argument that it's more productive to test modules through the application only applies to private, dedicated modules that will only ever be invoked in support of the use cases arising in the application.
Basically, it boils down to whether or not the piece of code is an independent product (where "product" could refer to something with "customers" internal to the organization).
In engineering, all building blocks that are separate products to be integrated into other products are rigorously tested on their own, whether they are integrated circuits, or steel cables or whatever.