← Back to team overview

nunit-core team mailing list archive

[Bug 655882] Re: Make CategoryAttribute inherited

 

I'm using a 'InheritableCategoryAttribute', as below:

using System;
using NUnit.Framework;

namespace Apt.Lib.Product.Data.Tests
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
	public class InheritableCategoryAttribute : CategoryAttribute
	{
		public InheritableCategoryAttribute(string name) : base(name)
		{
		}
	}
}


This attribute is applied to an abstract class, which provides some general functionality needed by all of my test fixtures:

    [TestFixture]
    [InheritableCategory("MyCategory")]
    public abstract class MyAbstractTests


What I would expect, is that any class extending MyAbstractTests should be found in MyCategory.  In practice, this is the case in the Resharper's unit testing interface, but not in the NUnit GUI and Command line.  As a result, I'm having trouble using this in a CI environment with Hudson

-- 
Make CategoryAttribute inherited
https://bugs.launchpad.net/bugs/655882
You received this bug notification because you are a member of NUnit
Core Developers, which is the registrant for NUnit Framework.

Status in NUnit Test Framework: Triaged

Bug description:
The attribute Category (used for making tests as being in a particular category) should be inherited. This would allow setting up an abstract base class for a certain type of test, marking it as [Category("Whatever")], and having NUnit recognize that every other test that inherits from that class is also in category "Whatever".

As of 2.5.7.10213, CategoryAttribute is not inherited.





Follow ups

References