How to use NUnit's [TestCase] attribute

Hi I've just downloaded the first publicly available nightly build of ReSharper 5

Liking it so far but one of the things I was looking forward to was the native NUnit support, which I thought would mean I could use the more modern features of NUnit.  

Specifically the [TestCase] attribute so I can parameterise tests.

However my tests that use [TestCase] are not being run, and they are showing up in the editor as never used code.

Will this feature be added?
Do I have to change some configuration?
Or do I have to go back to using another test runner outside of ReSharper?

Thanks for the great work!



Sorry, missed the fact that TestCase attribute can be used without Test attribute.
Fixed now, please try next EAP build to improve your tests


Wow that was nice and quick - thanks!

However...  when I run the tests using the [TestCase] attribute, it is counting all the different cases as 1 test.  Where as other test runners, such as NUnit or TestDriven.NET, count and report each case as a different test.

For instance if I'm testing a function that takes a string of comma separated numbers and returns their sum I might have some cases such as:

        [TestCase("1,2", 3)]
        [TestCase("1,2,3", 6)]
        public void Add_CommaSeperatedNumbers_SumOfNumbers(string numbers, int expected)
            int sum = Calculator.Add(numbers);    

            Assert.AreEqual(expected, sum);

The other test runners count this as 2 tests rather than just 1 as ReSharper is counting.

Also if I deliberately break one of the TestCases so they now read

        [TestCase("1,2", 3)]
        [TestCase("1,2,3", 10)]

The other test runners show me the one case that breaks and still counts the other case as working, but ReSharper indicates the whole thing is broken.

Will this be changed?  Should I raise a jira item for it?


It's pretty tricky to handle all those modern tests. For example, when using TestCaseSource test cases are created in runtime. We need to develop unified approach to handle such tests. We have some ideas how to do it, but don't have enough resources to do all cool things now.

You can create issue to track changes, if you wish. Don't worry we won't forget about this issue anyway.


OK, thanks for the explanation!


A reshearper does not support a following syntax

[TestCase(12,3, Result=4)]
[TestCase(12,2, Result=6)]
[TestCase(12,4, Result=3)]
public int DivideTest(int n, int d)
  return( n / d );

Fixed in build 1521.


Where can I find this build? All I can find is 1288.


TestCase attribute is working on beta. (5.0.1618.49)
But TestCaseSource not


Please sign in to leave a comment.