Build/Test Issues

NUnit TestCase with enum not working with dynamic analysis?

Started by GreenMoose on 5,612 views

v2.9.0.3

[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) ?
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.
Remco 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")
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.

Post a reply

Log in to reply.