What is Unit test, Integration Test, Smoke test, Regression Test and what are the differences between them?

Technology CommunityCategory: Software ArchitectureWhat is Unit test, Integration Test, Smoke test, Regression Test and what are the differences between them?
VietMX Staff asked 3 months ago
  • Unit test: Specify and test one point of the contract of single method of a class. This should have a very narrow and well defined scope. Complex dependencies and interactions to the outside world are stubbed or mocked.
  • Integration test: Test the correct inter-operation of multiple subsystems. There is whole spectrum there, from testing integration between two classes, to testing integration with the production environment.
  • Smoke test (aka Sanity check): A simple integration test where we just check that when the system under test is invoked it returns normally and does not blow up.
    • Smoke testing is both an analogy with electronics, where the first test occurs when powering up a circuit (if it smokes, it’s bad!)…
    • … and, apparently, with plumbing, where a system of pipes is literally filled by smoke and then checked visually. If anything smokes, the system is leaky.
  • Regression test: A test that was written when a bug was fixed. It ensures that this specific bug will not occur again. The full name is “non-regression test”. It can also be a test made prior to changing an application to make sure the application provides the same outcome.

To this, I will add:

  • Acceptance test: Test that a feature or use case is correctly implemented. It is similar to an integration test, but with a focus on the use case to provide rather than on the components involved.
  • System test: Tests a system as a black box. Dependencies on other systems are often mocked or stubbed during the test (otherwise it would be more of an integration test).
  • Pre-flight check: Tests that are repeated in a production-like environment, to alleviate the ‘builds on my machine’ syndrome. Often this is realized by doing an acceptance or smoke test in a production like environment.
  • Canary test is an automated, non-destructive test that is run on a regular basis in a LIVE environment, such that if it ever fails, something really bad has happened. Examples might be:
    • Has data that should only ever be available in DEV/TEST appeared in LIVE.
    • Has a background process failed to run
    • Can a user logon