3 ms·
A unit test tests a unit of code. An integration or functional test tests the interaction between multiple units of code, usually from the point of view of "use
by jrogers65 14y ago
A unit test tests a unit of code. An integration or functional test tests the interaction between multiple units of code, usually from the point of view of "user needs functionality X, functional test Y ensures that X works". Unit testing is not supposed to catch bugs, it is primarily to ensure a solid design. Integration/functional tests are primarily there to ensure that the code works.
It only makes sense to unit test code which is in the domain of architecture. This ensures that your domain model is solid.
It only makes sense to functional test code which is a concrete implementation running on top of said architecture. This ensures that the end user sees what they need to see.
One of the often quoted benefits of unit testing is that they run fast. That fact is only incidental. Not to mention the insanity of unit testing as much as you can just because they're faster to run - they are also an order of magnitude slower to write than functional tests.
tl;dr - use the right tool for the right job. Unit testing is for design/architecture. Functional testing is for concrete functionality.