The first C# tool that I’ve been looking at is NCover, a very popular piece of software intended to do static code analysis and integrate with a build system. NCover primarily focuses on calculating unit test coverage and cyclomatic complexity, two undeniably good metrics to drive test driven development and build maintainable code. NCover has an analysis tool called NCover Explorer, which allows you to view the results of the test run, reports and visualizations on each execution, and trending when analyzing multiple test runs.
The Good
NCover is easy to set up and integrates as an external tool in Visual Studio, which makes kicking off the process of code analysis easy. The Explorer allows some fairly flexible views of each code execution, which lines of code are not covered, and cyclomatic complexity at each method level. This is also configurable so you can few complexity on each branch or symbol, but I’ve not messed with that much yet. NCover allows you to exclude certain assemblies and provides roll-ups and reports of your coverage and what has changed in between runs. I find this valuable in my daily work, and these reports also integrate with build systems (which I should get to play with relatively soon.)
The Bad
The structure of your unit test solutions matter. We have a large codebase with a large set of unit tests, so it takes several minutes for the NCover report to run. There is some strangeness with the External Tool configuration as well, it requires you to have your Unit Test project highlighted or else it can’t kick off the assembly correctly and errors. The way that trending is handled is clunky and not as useful in the Explorer as they would hope. Our solution gets incremental improvements in each class, and the resolution of the graph on the NCover Explorer is not as helpful. Also, the trend analysis counts failed runs as zero coverage which really makes the trending less useful if you accidentally fat finger the External Tool or don’t highlight the project properly.
The searching capabilities within the Explorer are clunky and take too long to execute, and the reports are a bit difficult to comprehend. This could just be a limitation of my ability to interpret them though. I don’t know if there’s a plug-in for Visual Studio to provide in-IDE highlighting of uncovered lines of code, I will have to look into this further. It would be nice if this exists, since I know other tools provide this feature.
More on this soon, I suspect I will have more write once I try to integrate this with a build server and explore the features more closely.