Build/Test Issues

Code Coverage is only collected for the last test case run with [TestCaseSource]

Started by yworksjr on 3,260 views

Using NCrunch 2.14.0.8 with NUnit. I am using the [TestCaseSource] attribute for test cases of a particular test. Coverage data for that test is collected, but only for the very last test case returned from the source method.

For some reason I cannot reproduce this with a tiny test program, though. Sorry for now (I can't share my whole code here), I will investigate further.

Edited

Ok, solved it. This had to do with my test method taking an object as argument that didn't have a ToString(). Also every test had a description, but not a name.

Thus every test had the same name as far as NUnit was concerned, which probably led to this problem. ReSharper could still run them individually, though. NCrunch however, only sees one test case, despite there being a dozen.

Edited

yworksjr wrote:Ok, solved it. This had to do with my test method taking an object as argument that didn't have a ToString(). Also every test had a description, but not a name.

Thus every test had the same name as far as NUnit was concerned, which probably led to this problem. ReSharper could still run them individually, though. NCrunch however, only sees one test case, despite there being a dozen.


Yes - this is a known limitation in NCrunch as far as NUnit is concerned. NCrunch needs to generate names for the tests discovered by NUnit, and the only way it can do this is using the test's name. This means that tests must have a unique name when they are discovered from TestCaseSource.

Post a reply

Log in to reply.