# Unit vs Integration Tests in a Pipeline — CI/CD

Source: https://www.geekswithgeeks.com/en/cicd/cicd-testing-types

> Different tests catch different classes of bugs, at different costs.

## Unit tests

**Unit tests** check one function or component in isolation, with dependencies mocked out. They're fast — hundreds run in seconds — so they run on every single commit.

## Integration tests

**Integration tests** check that real pieces work together — an API talking to a real database, a service calling another service. They're slower and often run after unit tests pass, or on a schedule.

## The testing pyramid

Keep many fast unit tests at the base, fewer integration tests in the middle, and very few slow end-to-end tests at the top. An inverted pyramid makes CI slow and flaky.
