Build/Test Issues

TestCaseSource attribute incorrectly requires TestCase attribute, not Test?

Started by alexnorcliffe on 9,475 views

Sticking this on the forums in addition to the "submit bug report" in case others are getting this, or I'm doing it wrong :)

I've noticed that to use TestCaseSource NUnit attributes with NCrunch, you have to also decorate the test with the TestCase attribute. The NUnit docs (http://www.nunit.org/index.php?p=testCaseSource&r=2.5) say actually you should combine with the Test attribute, not TestCase. Combining with TestCase causes other runners to think that there's a separate test for which I've not provided enough arguments.

Using [Test] appears to be preferred by the R#6 test runner too, and NUnit's runner correctly shows no blank tests if you use the Test attribute, but NCrunch is now something I can't do without ;)
I'm amazed that it's possible to get TestCaseSource working at all, as so far I've made no effort to support it :)

Thanks for reporting this one. I'll have a look at it.
Does the same apply to Value and Range parameter attributes?
Marking a test with TestCase actually runs each range, but with Test it doesn't even identify that it's a valid test (black dots)
Likewise, this is actually invalid as it should be a Test attribute (to make it work in R#6 and NUnit runners)
Maybe TestCase unwittingly uses NUnit's real logic for spotting a test? :)
I think what's happening is that NCrunch only considers a test to be a test if it has either a [Test] attribute or a [TestCase] attribute with parameters on the method signature.

So if a test is marked with TestCaseSource and has parameters, then NCrunch thinks it can't be a [Test].

I don't think this one will be a big deal to fix. I'm planning a big blitz on NUnit 2.5 features soon, as many people are asking for them - this includes Value and Range parameter attributes :)
This issue should be fixed in the 1.35b build that was released this morning.
I can confirm that TestCaseSource is working nicely for one of the new tests I wrote to take advantage of it. There's nothing quite like generating 8000+ test cases dynamically. :)

Post a reply

Log in to reply.