The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Introducing: Unofficial NUnit Extensibility Framework - make your own test attributes easily!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Roy Osherove

Posts: 1807
Nickname: royo
Registered: Sep, 2003

Roy Osherove is a .Net consultant based in Israel
Introducing: Unofficial NUnit Extensibility Framework - make your own test attributes easily! Posted: Oct 5, 2004 12:51 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Roy Osherove.
Original Post: Introducing: Unofficial NUnit Extensibility Framework - make your own test attributes easily!
Feed Title: ISerializable
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/rosherove/Rss.aspx
Feed Description: Roy Osherove's persistent thoughts
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Roy Osherove
Latest Posts From ISerializable

Advertisement

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 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 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 NUnit.Extensions.ExtensibilityFramework 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:

- 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)

- Nunit.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.

- 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 NUnit.tExtensionsFramework project 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

Download the zip file here

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

I'd like to thank Jamie for helping me solve two simple and annoying bugs I just couldn't find with my  think head.

Read: Introducing: Unofficial NUnit Extensibility Framework - make your own test attributes easily!

Topic: Sorting in .NET Previous Topic   Next Topic Topic: Halloween Fun

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use