Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

NUnit generic test fixtures report "same name" error
jamiehumphries
#1 Posted : Friday, February 19, 2016 10:21:42 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/19/2016(UTC)
Posts: 2
Location: United Kingdom

Thanks: 1 times
Hello,

I am using NUnit's TestFixture attribute to set up parameterized test fixtures.

Unfortunately, NCrunch is only running them under the first set of parameters and giving me an error message like:
Quote:
NUnit tests have been detected with the same name

This project contains multiple NUnit tests that share the same name. This prevents NCrunch from uniquely identifying tests during their discovery and execution, distorting the reporting of test results. Ensure your tests always have a unique name within the scope of their project.


This is within the normal documented use cases of the TestFixture attribute, so is just a bug in NCrunch?

An example of such a test fixture is below (or see this Gist).
Code:
namespace NCrunchNUnitBug
{
    using NUnit.Framework;

    [TestFixture(23)]
    [TestFixture(42)]
    public class GenericTestFixture
    {
        private readonly int number;

        public GenericTestFixture(int number)
        {
            this.number = number;
        }

        [Test]
        public void Only_runs_once_under_NCrunch()
        {
            Assert.That(number, Is.EqualTo(23));
        }
    }
}

NCrunch inline coverage will report this as green because the first set of parameters (number = 23) passes the test, and will not run it with the second set of parameters (number = 42)

My environment is:

  • NCrunch 2.19.0.4
  • NUnit 3.0.1
  • Visual Studio Enterprise 2015
  • (Windows 10)


Thanks,
Jamie
Remco
#2 Posted : Friday, February 19, 2016 11:09:53 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,123

Thanks: 957 times
Was thanked: 1287 time(s) in 1194 post(s)
Hi Jamie,

Thanks for sharing this issue. This is caused by a known problem in which NCrunch isn't correctly identifying tests using parameterised fixtures under NUnit v3 - http://forum.ncrunch.net/yaf_postst1734_Parameterized-TestFixtures-not-fully-recognized-anymore-with-NUnit3.aspx. A fix is planned for the next release. Sorry for the trouble.
1 user thanked Remco for this useful post.
jamiehumphries on 2/19/2016(UTC)
jamiehumphries
#3 Posted : Friday, February 19, 2016 3:56:42 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/19/2016(UTC)
Posts: 2
Location: United Kingdom

Thanks: 1 times
Thanks Remco, I had a quick look around but missed that other thread. Glad to hear it is being worked on :)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.032 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download