---
title: "Introducing: XtUnit . An Unofficial Unit Testing Extensibility Framework - Add new attributes to NUnit or MbUnit easily!"
url: "https://osherove.com/blog/2004/10/5/introducing-xtunit-an-unofficial-unit-testing-extensibility.md"
canonical: "https://osherove.com/blog/2004/10/5/introducing-xtunit-an-unofficial-unit-testing-extensibility.html"
published: "2004-10-05T17:26:00"
updated: "2004-10-05T17:26:00"
tags: [".Net Original", "Agile Related"]
author: "Roy Osherove"
description: "Update : I've uploaded a more complete version of the framework and also changes the file name. please get it from here: http://www.teamagile.com/downloads/TeamAgile.XtUnit.Bin.zip…"
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/"
---

# Introducing: XtUnit . An Unofficial Unit Testing Extensibility Framework - Add new attributes to NUnit or MbUnit easily!

By Roy Osherove October 5, 2004 In [.Net Original](https://osherove.com/blog/category/net-original), [Agile Related](https://osherove.com/blog/category/agile-related)

**Historical article** · Originally published October 5, 2004; technical details may be outdated.

**Update**: I've uploaded a more complete version of the framework and also changes the file name. please get it from here:

[http://www.teamagile.com/downloads/TeamAgile.XtUnit.Bin.zip](http://www.teamagile.com/downloads/TeamAgile.XtUnit.Bin.zip)

[http://www.teamagile.com/downloads/TeamAgile.XtUnit.src.zip](http://www.teamagile.com/downloads/TeamAgile.XtUnit.src.zip)

if you have the earlier version.  (and just so you know - it works _perfectly_ with the [TestDriven.Net](http://www.testdriven.net/) tool suite)

---

One of the things that have bothered me the most since I got into the whole "Add database rollback to your unit tests" thing, is how much work it takes to make your test suite use this feature. I actually went and made a new binary of the NUnit Framework to support this new attribute. All this because there is no clear extensibility model for NUnit these days. Peli, on the other hand has a very nice way of extending MbUnit, but it still entails recompiling his library for this to work (or am I wrong?)

so - an idea came to me. A while ago [Peli](http://blog.dotnetwiki.org/) told me he had just found out about ContextBoundObjects and the ability to "intercept" method calls for pre and post processing. He said it might have some cool things that can be used with unit testing but we couldn't find something that was really cool to do with it.

The other day, while reading [this nice article](http://www.codeproject.com/csharp/AspectIntercept.asp) about implementing interception in your code, I got an idea: Maybe interception and Contexts are the best way for extensibility? So, I gave it a shot. And it turns out pretty darn cool I have to say.

**Introducing the XtUnit.Framework project**

With this project you are now able to add any attribute you can think of to you NUnit (or any other xUnit tests) with the ease of simply deriving from a base class. In the solution that you can download you will find 3 projects:

- **XtUnit.Framework:** The Extensibility framework base classes (2 of them - one to derive your test fixtures from, and one if you want to create your own attributes)
- _**XtUnit.Extensions.Royo**_ is a project that I made that uses these bases classes to add two attributes. The the now known \[Rollback\] attribute, and the second one is a simple \[Tracing\] Attribute. You can see the code and realize how simple it really is.
- **XtUnit.SampleTests:** a sample project with one simple fixture that uses the custom attributes.

now here are the cool things:

- You can now **\*fully\* debug** and step into your tests, and the \[Rollback\] attribute works perfectly!
-    **You are not depending on any specific framework**! Simply compile the XtUnit.Framework and XtUnit.Extensions.Royo projects with your Testing framework of choice and that's that! no more NunitX variants, thank god! Yes. This means you can use your existing NUnit 2.x projects with these attributes and even add your won. Just add these two projects to your solution and you're done.
- It is **very easy to create your own attributes** (and you can see how easy in the XtUnit.Extensions.Royo project)

I'd love to get your feedback. Have fun :)

I'd like to thank [Jamie](http://weblogs.asp.net/nunitaddin) for helping me solve two simple and annoying bugs I just couldn't find with my thick head.

## More in .Net Original

[All posts in .Net Original](https://osherove.com/blog/category/net-original)

- Oct 12, 2004

    ### [Introducing the Osherove.Interception framework](https://osherove.com/blog/2004/10/12/introducing-the-osheroveinterception-framework.html)

- Oct 12, 2004

    ### [\[Rediscovered\] Advanced debugging tips and stuff you never knew about the "Find" combo box](https://osherove.com/blog/2004/10/12/rediscovered-advanced-debugging-tips-and-stuff-you-never-kne.html)

- Oct 3, 2004

    ### [Upcoming talks and webcasts I'm involved with](https://osherove.com/blog/2004/10/3/upcoming-talks-and-webcasts-im-involved-with.html)

- Oct 3, 2004

    ### [DataSet hell - "Failed to enable constraints. One or more rows contain values...."](https://osherove.com/blog/2004/10/3/dataset-hell-failed-to-enable-constraints-one-or-more-rows-c.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/
