Public bug reported: I have a simple code example that shows the bug attached below. In my solution I have overridden the TestCase attribute. The result of this was very slow performance. During the analysis of this perfomance issue it was found that the nUnit framework constructs attributes a lot more than expected: * an attribute applied to a class under test is constructed twice, even if the class is never constructed. * an attribute applied to a testfixture is constructed six times * an attribute applied to a testmethod is constructed 13 times. This value varies as it exponentially increases when the number of tests increase.
I use nUnit 2.5.10. I have run these tests with both the nUnit runner and the Resharper v6.1.1000.82 runner. They render the same result. But: if I change my tests to the MSTest framework and run it with the VS2010 or VS2012 native runner, all attributes are constructed only once. If the MSTests are run with the Resharper runner another increase in the number of constructions can be seen. Below you will find the code that shows the issue: using System; using NUnit.Framework; namespace MyTests { [AttributeUsage(AttributeTargets.All, AllowMultiple = true)] public class WtfAttribute : Attribute { public static int CallCount = 0; public WtfAttribute() //every time the attribute is constructed the count is incremented by 1. { CallCount++; } } //this class is NEVER instantiated, but adding the attribute to it increases the callcount by 2. I expected it to be 1 due to reflection. [Wtf] public class MyDummyClass { } [TestFixture] //adding the attribute to MyTestClass increases the callcount by 6. //[Wtf] public class MyTestClass { [Test] //adding the attribute to MyTest increases the callcount by 13. //[Wtf] public void MyTest() { Assert.AreEqual(1, WtfAttribute.CallCount, "CallCount = " + WtfAttribute.CallCount); } } } ** Affects: nunitv2 Importance: Undecided Status: New ** Tags: attributes performance reflection -- You received this bug notification because you are a member of NUnit Developers, which is subscribed to NUnit V2. https://bugs.launchpad.net/bugs/1185704 Title: nUnit constructs TestCase attributes multiple times Status in NUnit V2 Test Framework: New Bug description: I have a simple code example that shows the bug attached below. In my solution I have overridden the TestCase attribute. The result of this was very slow performance. During the analysis of this perfomance issue it was found that the nUnit framework constructs attributes a lot more than expected: * an attribute applied to a class under test is constructed twice, even if the class is never constructed. * an attribute applied to a testfixture is constructed six times * an attribute applied to a testmethod is constructed 13 times. This value varies as it exponentially increases when the number of tests increase. I use nUnit 2.5.10. I have run these tests with both the nUnit runner and the Resharper v6.1.1000.82 runner. They render the same result. But: if I change my tests to the MSTest framework and run it with the VS2010 or VS2012 native runner, all attributes are constructed only once. If the MSTests are run with the Resharper runner another increase in the number of constructions can be seen. Below you will find the code that shows the issue: using System; using NUnit.Framework; namespace MyTests { [AttributeUsage(AttributeTargets.All, AllowMultiple = true)] public class WtfAttribute : Attribute { public static int CallCount = 0; public WtfAttribute() //every time the attribute is constructed the count is incremented by 1. { CallCount++; } } //this class is NEVER instantiated, but adding the attribute to it increases the callcount by 2. I expected it to be 1 due to reflection. [Wtf] public class MyDummyClass { } [TestFixture] //adding the attribute to MyTestClass increases the callcount by 6. //[Wtf] public class MyTestClass { [Test] //adding the attribute to MyTest increases the callcount by 13. //[Wtf] public void MyTest() { Assert.AreEqual(1, WtfAttribute.CallCount, "CallCount = " + WtfAttribute.CallCount); } } } To manage notifications about this bug go to: https://bugs.launchpad.net/nunitv2/+bug/1185704/+subscriptions _______________________________________________ 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