Archive for the ‘unit testing’ Tag

NCover Ignores C# 3.0 Automatic Properties

I’ve spent a good half hour trying to set up TestDriven.NET to analyse code coverage of my tests.
Here’s the scenario:

  • A new installation of VS 2008
  • A new installation of R# 4.0 (EAP build), TestDriven.NET 2.0 and xUnit 1.0 RC2
  • New solution with two projects project A (main project) and project B (xUnit unit tests)
  • Project A contains one class (MyClass) with three automatic properties
  • Project B contains one codefile with a test class testing automated properties of MyClass
  • I launch a test session with code coverage analysis
  • NCover Explorer shows absolutely no coverage for Project A

Puzzling. I immediately started googling to see if anyone else has had this problem and have gone through at least a dozen sites (including NCover FAQ page). Nothing. Not even close.

As a last resort, I’ve added an existing .cs file from another solution to Project A to see if that will trigger the coverage analysis to work correctly. And guess what – it did. Sort of.

Looking at the coverage results, it appears that C# automatic properties have no effect on the outcome of code coverage analysis – they are simply ignored.

Is this is a good thing or a bad thing? I haven’t decided.

Advertisements