Surely there is a difference between tests known as Integration and Unit tests (U tests). Yet this difference is not too obvious in many testing laboratories. So where does the border lie? To answer that we are to understand what are Unit tests exactly and what do testers mean by integration tests?
Any Unit Test is
There simply are several qualities that are making U tests truly Unit:
- U tests are repeatable, meaning same test may be run for dozens of times or more
- U tests do not change. Meaning it’s result is to be the same regardless of how many times is a tester running it
- U tests require independence of whatever is not in memory (changing values) like data bases, networks, file systems, etc.
- If it takes longer than, maximum, half a second for a U test run it’s not a good Unit test at all
- U test is testing but one tiny peace (use case). Not more, otherwise things are getting over complicated. That’s exactly the reason why they are called U tests.
If all those required conditions are not met at their best tests will be of poor value as they would either be way too long to waste time on or will be false-positive in their majority meaning such tests are not to be trusted. Now that we are clear with unit tests…
Any Integration Test is
Every other test that is not fitting under the description given above. Integration tests vary from one another. There are system tests, performance tests, acceptance tests, whatever tests. They are all Integration as long as they are not Unit. What are the exact differences here?
- Integration tests are using data that is changing constantly
- Objects with little control over may be created
- Integration tests often reach out to local or external system dependencies
- The same test case may be testing multiple things at same time
This is making Integration tests:
- Much slower than Unit Tests are
- Harder to recreate and more difficult to run fully
- There may be more issues with collecting result data
Does all of the mentioned above make Integration Tests useless? Surely, if they had zero value whatsoever no one would be using those now. Integration tests are best used when they were written beyond Unit Tests as an additional regression level. Or they are great with legacy code issues that was written before one started using Unit tests. And I am quite sure you may think of much more cases when Integration tests are to be used, right? Share ideas in comments!