Why Are Unit Tests Not Integration Tests?

Surely there is a difference between tests known as Integration and Unit 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 Unit Tests truly Unit:

  • Unit tests are repeatable, meaning same test may be run for dozens of times or more
  • Unit tests does not change. Meaning it’s result is to be the same regardless of how many times is a tester running it
  • Unit tests require independency 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 Unit test run it’s not a good Unit test at all
  • Unit 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 Unit 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!


TestFort Blog

About TestFort Blog

TestFort blog is an official blog of TestFort QA Lab company and is dedicated to various QA and software testing issues.

no comments yet

Be the first to comment this post!

Would you like to share your thoughts?

Images are for demo purposes only and are properties of their respective owners.
Old Paper by © 2018