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

Notification

Icon
Error

NUnit TestCase with enum not working with dynamic analysis?
GreenMoose
#1 Posted : Thursday, September 4, 2014 7:08:04 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 507

Thanks: 145 times
Was thanked: 66 time(s) in 64 post(s)
v2.9.0.3
Code:

[TestFixture]
    public class TestFixture
    {
        [TestCase(Numbers.One, "one")]
        [TestCase(null, "null")]
        public void NotFoundWithDynamic(Numbers? number, string expected)
        {
            Assert.Fail("TBD");
        }

        [TestCase("one", "two")]
        public void FoundWithDynamic(string number, string expected)
        {
            Assert.Fail("TBD");
        }

        public enum Numbers
        {
            One,
            Two,
        };
    }

Shouldn't both tests "be found" when using dynamic analysis (so I can e.g. pin them within the test itself) ?
Remco
#2 Posted : Thursday, September 4, 2014 7:48:48 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Sorry - just to clarify ...

Is the problem you're experiencing with the test entry points not being correctly identified?

.. Or is it with the test cases not being discovered at all?

I've managed to reproduce the former, but not the latter.
GreenMoose
#3 Posted : Thursday, September 4, 2014 7:52:55 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 507

Thanks: 145 times
Was thanked: 66 time(s) in 64 post(s)
Remco;6332 wrote:
Sorry - just to clarify ...

Is the problem you're experiencing with the test entry points not being correctly identified?

Correct. (They are executed with e.g. "run all tests")
Remco
#4 Posted : Thursday, September 4, 2014 7:59:08 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks. This looks like a problem with the enumeration messing with NCrunch's logic to try and identify the underlying method. The test cases will still run and behave normally, but the entry point won't be detected and you won't be able to navigate to the tests using the Tests Window (I think this is the bug report you've just submitted).

I'll need to address this as a code fix. Unfortunately 2.9 is on its way out the door at the moment, so this will probably need to be in the following release.
1 user thanked Remco for this useful post.
GreenMoose on 9/4/2014(UTC)
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.025 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download