---
title: "How do you avoid bugs in your unit tests?"
url: "https://osherove.com/blog/2006/7/22/how-do-you-avoid-bugs-in-your-unit-tests.md"
canonical: "https://osherove.com/blog/2006/7/22/how-do-you-avoid-bugs-in-your-unit-tests.html"
published: "2006-07-22T23:16:00"
updated: "2006-07-22T23:16:00"
tags: ["Agile"]
author: "Roy Osherove"
description: "Oren tries to answer from difficult questions about TDD. One of them is related to how you'd make sure that your tests don't have bugs in them - which is a very important aspect of trust-worthy tests : One of the best…"
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/"
---

# How do you avoid bugs in your unit tests?

By Roy Osherove July 22, 2006 In [Agile](https://osherove.com/blog/category/agile)

**Historical article** · Originally published July 22, 2006; technical details may be outdated.

[Oren tries to answer from difficult questions](http://www.lnbogen.com/CommentView,guid,da2b3730-972a-4318-bb99-7fa4ce964aa6.aspx) about TDD. One of them is related to how you'd make sure that your tests don't have bugs in them - which is a very important aspect of [trust-worthy tests](http://msdn.microsoft.com/msdnmag/issues/05/06/UnitTesting/):

One of the best ways to make sure that you test is not buggy (a smoke test, if you will), is to to make sure it fails when it should.
That's why in TDD, you always start with a failing test.
You actually \*run\* the test and watch it fail before you make it pass.
This has two reasons:

- To let you know that you have a bug.missing feature in your code, and to direct you to fix that target. now that the test passes, you can fix it , and then see the test fail.
- If you can't make the test fail when it should, it probably has a bug so if the test fails to begin with, and then passes when you fix the \*production\* code, you're good. but if your test passes from the get-go, before you even fixed the production code, you know your test isn't good enough..

## More in Agile

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

- Aug 22, 2006

    ### [It's Not Just Standing Up: Patterns for Daily Stand-up Meetings](https://osherove.com/blog/2006/8/22/its-not-just-standing-up-patterns-for-daily-stand-up-meeting.html)

- Aug 16, 2006

    ### [SharpRobo - Winform UI Unit Testing made easier?](https://osherove.com/blog/2006/8/16/sharprobo-winform-ui-unit-testing-made-easier.html)

- Jul 19, 2006

    ### [Oren is grokking Test Driven Development](https://osherove.com/blog/2006/7/19/oren-is-grokking-test-driven-development.html)

- Jul 10, 2006

    ### [TestDriven.NET - Pro and Enterprise editions announced](https://osherove.com/blog/2006/7/10/testdrivennet-pro-and-enterprise-editions-announced.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/
