You're correct. There is no workaround because NUnit does not look at
inherited attributes
with a few exceptions - TestFixture for example.

I'll raise the question of changing this behavior globally on the mail
list. If folks see no
problem with it, we can make the change.

Charlie

On Wed, Nov 3, 2010 at 12:04 PM, Alex Franz <655...@bugs.launchpad.net> wrote:
> 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 subscribed to NUnit
> Framework.
>

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



_______________________________________________
Mailing list: https://launchpad.net/~nunit-core
Post to     : nunit-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~nunit-core
More help   : https://help.launchpad.net/ListHelp

Reply via email to