3 ms·
The biggest difference is typically that unit tests don't require a test fixture of any kind, and are expected to run wherever the compiler runs. You typically
by tsimionescu 5y ago
The biggest difference is typically that unit tests don't require a test fixture of any kind, and are expected to run wherever the compiler runs. You typically expect a huge battery of unit tests to run in seconds, and they are normally expected to run before every commit, even for every build on a dev machine. A new contributor is expected to be able to do something close to "apt get langauge-toolchain && git clone $repo && make build && make unit" and see that all unit tests pass. However, they are also expected to sometimes miss obvious bugs, like "the queries we generate are not valid with the new MySQL flags we set". They often need to be changed even for refactorings, as they typically cover implementation details, not just the public API.
In contrast, integration tests typically require a test fixture of some kind and are thus expected to require more complex setup instructions, perhaps even access to shared resources (like a DB server with a large batch of test data that can't realistically be replicated, or a testing instance of a real microservice you integrate with). By virtue of often requiring IO (network operations, DB operations etc), they are often considerably slower, so that they become impractical to run at every build. The upside is that they catch errors that were not obvious from the code, and they usually give you a high degree of assurance that a user of your service will at least not encounter silly bugs. A break in the integration tests after a redactor is also often a potential sign you've broken backwards compatibility of your API.