flow.
"Flow is a condition of deep, nearly meditative involvement." - Tom DeMarco

Associating Tests With Their Target Objects

Thursday, July 12, 2007 4:07 PM
For the last few days I've been thinking to myself how convenient it would be to associate an object under test with the TestFixture that's exercising it.  Say, with an attribute.  That way you could see at a glance what the object under test is and jump to it in your editor if you like.

Well, today I discovered that MbUnit actually has an attribute already that does that very thing:  the TestsOnAttribute.
This attribute lets you specify the exact type under test so that you can create a more defined relationship between the two.

    /// <summary>

    /// Fully exercises the <see cref="Account"/> object.

    /// </summary>

    [TestFixture]

    [TestsOn(typeof(Account))]

    public class AccountTest

    {

        . . .

    }


Not enough, how about this?  MbUnit's GUI runner has a tree node specifically for TestOns which will let you easily browse your tests by the target objects without having to wade through 5 levels of namespaces.  Check out the screenshot for an example.

kick it on DotNetKicks.com

Feedback

# re: Associating Tests With Their Target Objects

Hot damn!
I had not idea about that and I have been using MbUnit for years. How did you figure that out? Is there a way to associate to a method/member? 7/13/2007 9:31 AM | Jay Flowers

# re: Associating Tests With Their Target Objects

Just stumbled onto it...actually when I was looking for TestCategory. Doesn't look like there's a way to associate on a member level though, the TestsOn attribute is only valid for the class level. I could see that being a very cool feature request though...

Thanks for the comment, I'm glad it helped you out!
Jeremy 7/13/2007 11:12 AM | Jeremy

Post a comment





 

Please add 1 and 6 and type the answer here: