Repaso
EspaƱol
TestingCoreTST-24

Unit test vs integration test?

Options

  1. They are the same thing under two different names
  2. Unit: one piece alone. Integration: parts together (Correct option)
  3. Integration tests are always done manually by hand
  4. Unit tests always need a running server to work

Answer

A unit test checks one small piece (a function or class) in isolation; an integration test checks several parts working together, e.g. code + real database

Why

Unit test: tiny and fast (milliseconds). Tests one function with its dependencies replaced by fakes. When it fails, you know exactly where.

Integration test: checks that real parts fit together: your repository with a real PostgreSQL, or your API with its middleware. Slower but catches problems unit tests can't.

End-to-end tests go further and test the whole system like a user.

Remember

Unit = one piece alone. Integration = pieces together.

Key terms

Practice this question in Repaso