---
title: "lowering the adoption barrier for unit testing: doctest in python"
url: "https://osherove.com/blog/2008/12/3/lowering-the-adoption-barrier-for-unit-testing-doctest-in-py.md"
canonical: "https://osherove.com/blog/2008/12/3/lowering-the-adoption-barrier-for-unit-testing-doctest-in-py.html"
published: "2008-12-03T15:18:03"
updated: "2008-12-03T15:18:03"
tags: ["Agile", "Unit Testing"]
author: "Roy Osherove"
description: "One area that I didn’t know about was brought to me by an attendee in one of the conferences I was in. It’s a simple idea, really: write the tests for a method as part of the method’s documentation. but make them…"
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/"
---

# lowering the adoption barrier for unit testing: doctest in python

By Roy Osherove December 3, 2008 In [Agile](https://osherove.com/blog/category/agile), [Unit Testing](https://osherove.com/blog/category/unit-testing)

**Historical article** · Originally published December 3, 2008; technical details may be outdated.

One area that I didn’t know about was brought to me by an attendee in one of the conferences I was in. It’s a simple idea, really: write the tests for a method as part of the method’s documentation. but make them executable.

In python, they have something called [doctest](http://www.python.org/doc/2.5.2/lib/module-doctest.html) (thanks to Alf Lervåg for the emails!)

[here’s a PDF](https://svn.python.org/www/branches/rest2web/pydotorg/pycon/dc2004/papers/4/PyCon2004DocTestUnit.pdf) with more in.

With the upcoming WPF editor in VS 2010, we could find a good use for such a thing. I think it might ease adoption of unit testing becuase it’s much easier to accomplish if you can write the test right there where the method you’re writing is. The cons are lack of intellisense, compilation errors and such, but it’s something to look at, indeed.

## More in Agile

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

- Jan 13, 2009

    ### [Unit Testing in VB.NET – with Typemock Isolator (with a free license offer)](https://osherove.com/blog/2009/1/13/unit-testing-in-vbnet-with-typemock-isolator-with-a-free-lic.html)

- Dec 14, 2008

    ### [TDD Case Studies and research](https://osherove.com/blog/2008/12/14/tdd-case-studies-and-research.html)

- Dec 3, 2008

    ### [Isolation frameworks – lessons from the wild](https://osherove.com/blog/2008/12/3/isolation-frameworks-lessons-from-the-wild.html)

- Nov 26, 2008

    ### [Isolation Syntax for VB.NET - Your comments please](https://osherove.com/blog/2008/11/26/isolation-syntax-for-vbnet-your-comments-please.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/
