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.