Last weekend I was bit of busy. This time I found it too boring to work with PartCover and suffer its well known x64 unfriendliness. I was looking for a long term solution and could not help hacking SharpDevelop to meet my needs. That led to the birth of OpenCover addin for SharpDevelop.
This post is going to document some history about SharpDevelop’s unit test coverage tool integration. So if you are just interesting in the addin itself, please scroll to the bottom of this post and grab the code.
SharpDevelop with NCover
SharpDevelop has been a test driven development IDE for years and personally I think this is one of its design goals. But its code coverage support just started in 2006 .
At that time, NCover (authored by Peter Waldschmidt) seems to be the only feasible solution, and its was free. But the turn to closed source development  of course made its way out of SharpDevelop, as SharpDevelop has been a platform for all free/open source utilities .
NCover continues to evolve though, and now it is almost the best option you have for .NET development. It supports many awesome features, such as branch coverage and Visual Studio integration .
If you are an author of a similar tool, you will understand how much effort is required to develop a tool as large as NCover. At that time there was no Mono.Cecil nor Microsoft CCI nor Gendarme, which means NCover team have to write almost everything from scratch. So it is reasonable to commercialize this project and receive funding/sell licenses in order to speed up the development.
SharpDevelop with PartCover
PartCover was started in 2008  by Dmitri Kashtanov . Several developers have worked on it during the years, but it was never as mature as NCover. There were many issues reported but not fixed until recently, such as
- .NET 4 support
- Crash on x64 
Therefore, its last maintainer Shaun Wilde decided to abandon it and started OpenCover .
OpenCover’s Pro’s and Con’s
OpenCover is a wonder project in the following way,
- Its Wiki pages answer most of your questions.
- Its developer answers almost all queries/questions.
- It is feature rich and almost covers all things a beginner/intermediate needs.
- Its code base can be downloaded and compiled without any hacking. Just download and compile it.
Shaun has done an amazing job if you review his code :)
However, its weakness is also obvious,
- It depends on another project for reporting, Report Generator . Don’t get me wrong. Report Generator from Daniel Palme is good. But since it is not co-evolving with OpenCover, it does not explore every bit of OpenCover as best as it could.
- It does not have any IDE integration (no VS addin nor SD addin). Can’t imagine how to write C# programs with an IDE.
- Its output format is special.
SharpDevelop with OpenCover
OK. Now it’s my time. I think I am almost the best candidate for this piece of work, as
- I wrote a SharpDevelop addin in the past, called Alex (AStyle addin ).
- I know PartCover and OpenCover.
- I have time.
- I need such an addin for my own open source projects.
So last weekend I forked SharpDevelop and started my hacking .
Information on Beta 1
The following are the steps you need to compile my work and enjoy the very first Beta of this addin,
- Checkout the code or download the ZIP from https://github.com/lextm/SharpDevelop
- Upzip the package if you downloaded the ZIP.
- Execute releasebuild.bat.
- Launch this customized SharpDevelop build using bin\SharpDevelop.exe.
The current warnings are,
- The coverage result is different from the one generated by PartCover. This is something caused by OpenCover’s breaking changes. It is very hard to say which calculation approach is better, so you might learn to adapt to the OpenCover approach.
- Not all the unit test cases have passed yet. I need to spend some more time cleaning up.
- Based on Shaun’s suggestions I might change the coverage calculation in a later build.
If you meet any issues with this Beta build addin, please leave the detail information under this pull request,
I will spend time fixing them before finalizing the 1.0 release.