Click here to Skip to main content
15,884,353 members
Articles / STL

dotCover - A New Kid on the (development) Block

Rate me:
Please Sign up or sign in to vote.
3.50/5 (2 votes)
31 Jul 2010CPOL5 min read 9.5K   2   1
dotCover - a new kid on the (development) block

These days, JetBrains (the manufacturer of ReSharper (R#)) released the beta version of a new code coverage tool – dotCover. Because I’m a big fan of the R# add-in, I was particularly curious about having a first look at the newest JetBrains child. Notably, I wanted to see how it would take advantage of its deep R#/VS integration to make code coverage an integral part of a developer’s working experience. Here are my first impressions about it…

Note: Because I’m using NCover for Code coverage analysis at the moment, I cannot help comparing these two tools, although this might not be totally appropriate: dotCover is designed to deeply integrate with R# and Visual Studio, whereas NCover is a stand-alone application. Also, NCover is a mature and feature-rich application, whereas dotCover is in its early infancy…


Some useful related resources (links to website, documentation material and some videos) can be found in my toolbox on Delicious:


About Code Coverage

Much has been written about Code Coverage and about what it can do and what not – see for example here and here. The bottom line is: The single useful aspect of Code Coverage is that it shows you which parts of your production code are NOT covered by any tests, and thus gives you a basis to decide upon those areas: You simply may have overlooked it, or you may have made the explicit decision to not test it.

And this is exactly what I’m interested in when writing tests - be it after the fact (i.e., covering a pre-existing codebase with tests) or be it when authoring new code in a TDD process: I want to quickly see which parts of the production code are covered with tests, and I want to be able to quickly jump to and inspect code which is not. In short: It’s productivity what I’m looking for in the first place. In-depth information - like it is provided by NCover - is part of a broader picture that becomes important when deeply analyzing an entire codebase or monitoring historical trend data. But for now, let’s exclusively focus on the coding process itself…

Running Tests with Coverage

DotCover will add a new item to the familiar R# menu, which allows you to run tests with coverage just like you would run ‘normal’ tests from R#:

RunningFromReSharper

DotCover also adds a new tab to the R# Unit Test Sessions tool window, showing the results of the current coverage run:

CoverageToolWindow

 From there, you can directly navigate to the code under test via double click, which will be highlighted in red and green according to the measured test coverage:

HighlightCodeAreas

Navigating from Production Code to Test Code

It is also possible to browse your test code <-> production code connections from the other direction. After a coverage run, dotCover will show you which tests are operating on a selected code line when right-clicking it and choosing Show Covering Tests form the context menu:

ShowCoveringTests

This will open up a popup window like the one below, giving you a list of relevant tests:

ListOfCoveringTests

Summary

The dotCover tool makes code coverage analysis as simple and fast as it was never before. It doesn’t provide all the sophisticated features that NCover has (e.g. branch coverage or trend analysis, to name just two…), but instead it integrates deeply with your coding process and lets you browse and navigate between test code and production code inside VS with only one or two mouse clicks while highlighting the covered/uncovered code areas. Unlike NCover, there’s no need to switch between different applications and to figure out complicated sets of options and/or command lines. Especially when used with a consequent TDD process (like the one I described here in some detail), dotCover is a great help in writing tests and can strongly boost a developer’s productivity.

That’s the pro side of the coin. The contra for now is, that there is not yet any automation support – meaning that it’s not yet possible to use dotCover coverage reports from a Continuous Integration process. This is where NCover is quite ahead at the moment: It allows you to generate nice and detailed coverage reports and data from the command line or via MSBuild/NAnt tasks and thus can seamlessly be integrated with a CI tool like e.g. CruiseControl.NET.

Conclusion

DotCover does a great job on the development side of things, because it integrates perfectly with R# and VS. From a developer’s point of view, code coverage never was easier. This part of the picture is really impressing IMHO. (And as a side note: Although the current version is in a quite early beta state, I found it to be impressingly stable…)

However, there is not yet any automation support (a command-line interface and probably some MSBuild and NAnt tasks), so dotCover cannot be integrated with any Continuous Integration tool at the moment, which (at least for me) means that it’s not yet ready for production regarding the current feature set. But as said before, dotCover is in an early beta, and these features are announced for the final 1.0 version. Like the JetBrains people put it:

dotCover is still in its infancy and we’ve got a lot planned in terms of features and functionality. Quite a few people have asked whether it will support running coverage reports from a console, which is important for continuous integration. dotCover will support running from a console with some basic functionality, and we have plans to include specific features for CI processes.

So let’s just look forward to the things to come…

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Freelancer
Germany Germany
I'm a freelance software developer/architect located in Southern Germany with 20 years of experience in C++, VB, and C# software projects. Since about ten years I do all my coding exclusively in C# for business application development - and nowadays Python for Data Science, ML, and AI.
I am especially dedicated to Test-driven development, OO architecture, software quality assurance issues and tools.

Comments and Discussions

 
GeneralMy vote of 2 Pin
Andy Neillans5-Jan-14 21:46
professionalAndy Neillans5-Jan-14 21:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.