---
title: "Unit testing vs. Integration Testing : The Restaurant Analogy"
url: "https://osherove.com/blog/2008/5/31/unit-testing-vs-integration-testing-the-restaurant-analogy.md"
canonical: "https://osherove.com/blog/2008/5/31/unit-testing-vs-integration-testing-the-restaurant-analogy.html"
published: "2008-05-31T12:12:31"
updated: "2008-05-31T12:12:31"
tags: ["Agile", "Art Of Unit Testing", "Unit Testing"]
author: "Roy Osherove"
description: "Here's an analogy I came up with to explain the difference between unit tests and integration tests. Imagine going to a restaurant with a bunch of your friends. there are some couples there as well as singles. At the…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Unit testing vs. Integration Testing : The Restaurant Analogy

By Roy Osherove May 31, 2008 In [Agile](https://osherove.com/blog/category/agile), [Art Of Unit Testing](https://osherove.com/blog/category/art-of-unit-testing), [Unit Testing](https://osherove.com/blog/category/unit-testing)

**Historical article** · Originally published May 31, 2008; technical details may be outdated.

Here's an analogy I came up with to explain the difference between unit tests and integration tests.

Imagine going to a restaurant with a bunch of your friends. there are some couples there as well as singles. At the end of the meal, it is time to pay. Unit testing is like giving a separate bill to each couple or single. Each person knows only what they needs to pay as well as tip, but do not care what anyone else had, or what the total meal amount is. as long as they pay what they need, they can go home peacefully.

Integration testing is like giving one big check to the group, with everyone having to calculate on their own how much they need to pay. sometimes everyone things they are good, but in the end the total amount may be too high or too low. There is a lot of interaction going on to decide who pays for what and who has already paid.

## More in Agile

[All posts in Agile](https://osherove.com/blog/category/agile)

- Jun 13, 2008

    ### [Unit Testing Interview at TechEd](https://osherove.com/blog/2008/6/13/unit-testing-interview-at-teched.html)

- Jun 9, 2008

    ### [Fit/Fitnesse Fixture Gallery -Real world help for FIT and Fitnesse users](https://osherove.com/blog/2008/6/9/fitfitnesse-fixture-gallery-real-world-help-for-fit-and-fitn.html)

- May 19, 2008

    ### [Two Faced Commits - how the ALT.NET Community is becoming more and more dogmatic](https://osherove.com/blog/2008/5/19/two-faced-commits-how-the-altnet-community-is-becoming-more.html)

- May 18, 2008

    ### [Tough Questions about unit testing - Your comments required](https://osherove.com/blog/2008/5/18/tough-questions-about-unit-testing-your-comments-required.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
