Search code examples
c#visual-studio-2013nunittestcase

NUnit produces empty empty parameter test when using TestCaseSource and objects


Using the sample on the NUnit website (http://www.nunit.org/index.php?p=testCaseSource&r=2.5):

    [TestCase]
    [TestCaseSource("DivideCases")]
    public void DivideTest(int n, int d, int q)
    {
        Assert.AreEqual(q, n / d);
    }

    object[] DivideCases =
    {
        new int[] {12, 3, 4},
        new int[] {12, 2, 6},
        new int[] {12, 4, 3}
    };

produces an empty parameter call to DivideTest which obviously fails with "No arguments were provided". ie, it makes a DivideTest() call.

How can I fix this? Installed NUnit from nuGet. ver 2.6.4.


Solution

  • You have a [TestCase] attribute on yours that isn't on the sample.

    The sample attributes:

    [Test, TestCaseSource("DivideCases")]
    

    Yours:

    [TestCase]
    [TestCaseSource("DivideCases")]