← Back to team overview

nunit-core team mailing list archive

[Bug 1208356] Re: Properties are not applied for parameterized tests

 

You're probably right about the docs. We didn't originally include the info
because it seemed "obvious" based on how .NET applies attributes - I guess
only "obvious" to the folks who wrote the code.

The change you suggest is possible. It's also logical for categories: that
is, putting a fixture in a category means putting all the test cases in
that category. However, it's not universally applicable to all attributes.
What this means is that NUnit would have to specify which attributes, when
placed on a method, apply to the suite that is created and which ones apply
to the individual test cases. We could probably do this by use of an
interface or alternatively by an attribute on the  attribute definition.

I explain the complexity of the change so you'll understand why I'm
changing this to the NUnit 3.0 project!

Charlie


On Mon, Aug 5, 2013 at 9:01 AM, Dunemaster <vklava@xxxxxxxxx> wrote:

> Well, I think applying the property to all test cases is reasonable
> behavior.
> Otherwise, mentioning in [TestCase] and [Property] documentation that they
> do not work together will be a good thing, may it will save an hour for
> several people
>
> --
> You received this bug notification because you are subscribed to NUnit
> Extended Testing Platform.
> https://bugs.launchpad.net/bugs/1208356
>
> Title:
>   Properties are not applied for parameterized tests
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/nunitv2/+bug/1208356/+subscriptions
>


** Project changed: nunitv2 => nunit-3.0

-- 
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.
https://bugs.launchpad.net/bugs/1208356

Title:
  Properties are not applied for parameterized tests

Status in NUnit Test Framework:
  New

Bug description:
  NUnit 2.6.2
  I have a custom attribute for my property 

      [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
      internal class NeedRecreateDataAttribute : PropertyAttribute
      {
          public const string PROPERTY_NAME = "NeedRecreateData";

          public NeedRecreateDataAttribute()
              : base(true)
          {

          }
      }

  It is applied ok when used with [Test] attribute:

        [Test]
          [NeedRecreateData]
          public void Test_Assign_String()
          {
          ...
  } 

  
       [TearDown]
          public void TestTeadDown()
          {
              if (TestContext.CurrentContext.Test.Properties.Contains(NeedRecreateDataAttribute.PROPERTY_NAME))
              {
                  PrepareFixtureData();
              }
          } 

  
  But when paired with [TestCase] attribute, the property is not applied
  (TestContext.CurrentContext.Test.Properties.Contains(NeedRecreateDataAttribute.PROPERTY_NAME) == false)

To manage notifications about this bug go to:
https://bugs.launchpad.net/nunit-3.0/+bug/1208356/+subscriptions


References