---
title: "[Article] Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears"
url: "https://osherove.com/blog/2005/12/13/article-unit-testing-tips-write-maintainable-unit-tests-that.md"
canonical: "https://osherove.com/blog/2005/12/13/article-unit-testing-tips-write-maintainable-unit-tests-that.html"
published: "2005-12-13T16:54:00"
updated: "2005-12-13T16:54:00"
tags: ["Agile Israel News", "Agile Related", "Cool Articles", "Team Agile News", "Testing Guidelines"]
author: "Roy Osherove"
description: "My latest MSDN Magazine article titled \" Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears \" is out in the online January Issue here. It's based on real issues, guidelines I've…"
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/"
---

# \[Article\] Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears

By Roy Osherove December 13, 2005 In [Agile Israel News](https://osherove.com/blog/category/agile-israel-news), [Agile Related](https://osherove.com/blog/category/agile-related), [Cool Articles](https://osherove.com/blog/category/cool-articles), [Team Agile News](https://osherove.com/blog/category/team-agile-news), [Testing Guidelines](https://osherove.com/blog/category/testing-guidelines)

**Historical article** · Originally published December 13, 2005; technical details may be outdated.

My latest MSDN Magazine article titled

"[Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears](http://msdn.microsoft.com/msdnmag/issues/06/01/UnitTesting/default.aspx)"

is out in the online January Issue here.

It's based on real issues, [guidelines I've developed](http://weblogs.asp.net/rosherove/category/9834.aspx?Show=All) and questions I've encountered during the last few years teaching and mentoring teams in test driven and agile development, and contains general rules I think no person writing unit tests should go without. It took blood sweat and tears to make this one, and I hope you like it (though the editor seems to have thoroughly cut down large pieces of it including changing all my samples to be VB.NET instead of C#.. especially the part that says that this article is targeted at developers using any version of a unit test framework out there.. grr!)

Anyways, here's the summary:

"There's a lot of talk these days about unit testing and how one should go about writing unit tests for their applications under different scenarios (for starters, see my June 2005 _MSDN_®_Magazine_ article on testing your data layer, available at [Know Thy Code: Simplify Data Layer Unit Testing using Enterprise Services](http://msdn.microsoft.com/msdnmag/issues/05/06/UnitTesting/)). That means there are a lot of developers who say to themselves (and to their teams) "_Hey, we should start writing tests, too_!" And so they begin writing unit test upon unit test until they reach a point where the tests themselves become a problem. Perhaps maintaining them is too hard and takes too long, or they are not readable enough to make sense, or maybe they have bugs.

It is at that point that developers are forced to make a tough decision: dedicate precious time to improving their tests or ignore the problem, effectively throwing away their hard work. The cause of this problem is simply inexperience writing unit tests.

In this article, I'll try to bring you some of the most important practices I've learned over the years while developing and consulting, and while training developers. These tips should help you write effective, maintainable, and robust unit tests. And I hope this advice helps you to avoid huge amounts of wasted time and effort."

## More in Agile Israel News

[All posts in Agile Israel News](https://osherove.com/blog/category/agile-israel-news)

- Dec 15, 2005

    ### [Agile Israel News: RSS Feed and 3rd TDD Workshop are now open!](https://osherove.com/blog/2005/12/15/agile-israel-news-rss-feed-and-3rd-tdd-workshop-are-now-open.html)

- Dec 15, 2005

    ### [Reminder: Agile Israel meets today!](https://osherove.com/blog/2005/12/15/reminder-agile-israel-meets-today.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/
