11

Visual Studio C# Express edition is an adequate IDE when it comes to writing C# - and NUnit is an adequate framework for writing unit tests. This pairing, however, isn't sufficient to establish the code-coverage of these tests.

I realise that the Professional and Ultimate editions integrate with MSTest and provide fully integrated code-coverage... but this restricts verification of coverage to those who have purchased the relevant IDE - which isn't ideal.

I'm not worried about integration of coverage analysis into the IDE... that's one approach, but I'd be equally happy with a report generated by a batch process... this could be integrated into continuous integration.

I am concerned about the quality of the coverage metrics - for example, I'd want branch-level coverage analysis not just line-level.

I'm imagining that Visual Studio Professional/Ultimate is not an idea solution for developers in a Mono environment... can anyone tell me what's typically used in such a context?

aSteve
  • 1,956
  • 1
  • 20
  • 35
  • Is it essential to you that you dont pay? Else you have more options, such as DotCover - http://www.jetbrains.com/dotcover/ – christofr Jul 22 '11 at 13:15
  • Why are people down-voting this question? – Vijay Gill Jul 22 '11 at 13:22
  • @Vijay, While I guard myself and say I didn't downvote; I imagine because of the lack of research made. There's plenty of this kind of question available already here, there's plenty of articles on the merits of different tools searchable via google, etc. =) – J. Steen Jul 22 '11 at 13:29
  • 1
    @J. Steen: I was not accusing anybody there :) and if a question needs down-vote then it should get. I am new to this community, so I am learning about how thing go on here. – Vijay Gill Jul 22 '11 at 13:33
  • @Vijay, Generally, you can get hints about the features and functions of SO by hovering your mouse over controls and links. There'll quite often be an explanatory tooltip. =) – J. Steen Jul 22 '11 at 13:35
  • @J. Steen: Never knew about that mouse hovering tip :) Thanks. – Vijay Gill Jul 22 '11 at 13:38
  • See the list of test coverage tools at http://stackoverflow.com/questions/276829/code-coverage-for-c-net – Ira Baxter Jul 22 '11 at 14:40
  • I apologise if my question appears a FAQ. I have searched, but have not found suitable answers. For my current purposes, it is imperative that the coverage solution has zero financial cost. I've used great commercial tools before - but, for this project, I need tools anyone can download and install without need for a budget. I found PartCover - but this project seems to have been inactive since 2008 - so I doubt it's good for C#4.0; I also found TestCacoon (http://www.testcocoon.org/) which is great for C++ and has some C# support though none for the 2010 VC#. – aSteve Jul 22 '11 at 15:39
  • PartCover does support .NET4 (I know I added it) also the link by Ira Baxter may be a FAQ but it has not been maintained with latest developments – Shaun Wilde Jul 23 '11 at 23:42

4 Answers4

8

NCrunch is pretty cool. It gives you visual indicators on the left side of your code to let you know if it is covered, and if the tests on it have passed.

http://www.ncrunch.net/

CassOnMars
  • 6,153
  • 2
  • 32
  • 47
  • NCrunch looks good... Many thanks... However - I don't think it's suitable for what I want right now as it's only free during its beta... Whatever strategy I adopt, I want to be sure it will 'work' for years to come... – aSteve Jul 22 '11 at 15:43
  • 1
    There is also a tool called Continuous Tests (http://continuoustests.com/) that offers similar functionality – Shaun Wilde Jul 23 '11 at 04:17
5

OpenCover and PartCover are currently the two main tools.

PartCover is the oldest and is no longer actively maintained on SourceForge. Support for this utility has since moved to GitHub (PartCover on GitHub)

OpenCover is newer and is also on GitHub (OpenCover on GitHub) it has 64 and 32 bit support and overcomes some of the limitations that PartCover has (memory and results delivery).

Both are supported by TypeMock (I think OpenCover support is being added soon see Can Opencover be used with TypeMock Isolator?)

Reports for both PartCover and OpenCover can be supplied using ReportGenerator ()

Community
  • 1
  • 1
Shaun Wilde
  • 8,228
  • 4
  • 36
  • 56
  • Many thanks! OpenCover looks as if it is a real possibility - especially as it seems more likely to have extensive branch coverage support than PartCover. Thanks also for the pointer to ReportGenerator... that's very helpful. – aSteve Jul 23 '11 at 12:42
1

PartCover?

Or SharpDevelop? SharpDevelop is an alternate IDE which has more features than Express version of VS.

Vijay Gill
  • 1,508
  • 1
  • 14
  • 16
  • Many thanks - I'd head of SharpDevelop - but had assumed it would be significantly inferior to Visual Studio (Express). I'll definitely give it a try... but I note it doesn't take me beyond PartCover as a coverage tool... – aSteve Jul 22 '11 at 15:44
  • I don't understand "it doesn't take me beyond..." part of your message. SD is fairly good IDE and I know some people using it to develop commercial apps with better integration of unit tests/code coverage/version control all from IDE. – Vijay Gill Jul 22 '11 at 15:48
  • Sorry, I wasn't clear. I'm impressed by what I've now seen of SharpDevelop. I'm considering it as an alternative to Visual Studio independently of code-coverage. The "take me beyond" PartCover is because SD uses PartCover to provide its code-coverage features... and, according to SourceForge, the latest PartCover release was in version 2.2 from September 2008... so I doubt that will have good support for features introduced in C#4.0 and shipped with Visual Studio 2010. I'd hoped to find something more up-to-date and actively supported than that. – aSteve Jul 22 '11 at 16:57
  • https://github.com/sawilde/partcover.net4 - this link is more up-to-date and also claims to support .Net 4. – Vijay Gill Jul 22 '11 at 23:06
0

I'm surprised no one has mentioned this, but visual studio Team Edition comes with a code coverage tool. ( It's part of the Team Tools suite). Also when you run unit tests in VS Team Edition, it performs code coverage AUTO-MAGICALLY. :)

So it's free in a sense if you already have Team Edition, but of course Team Edition costs a bit more. So there you go.

C.J.
  • 15,637
  • 9
  • 61
  • 77