dbones notes
its a geek thing

Getting MbUnit to work with Visual Studio Code Coverage

April 16, 2009 00:13 by Dave

Whilst working on open source project I am detracting away from MsTest in favour for MbUnit (plus this has awesome functionality). The thing was I still wanted to have code coverage within Visual Studio, Its a great way to see what code is being hit by the tests which have been written. Upon researching this I have found a couple of ways to get MbUnit Code Covered.

Way 1

Lets start with the Official Runner

if you open the XML of the Test project and change the Project GUID to"{3AC096D0-A1C2-E12C-1390-A8335801FDAB}" which signals to VS this is a test project, for a complete and CORRECT guide on this method please follow the steps detailed here (from the Lead Developer of MbUnit!)..... However he does mention doing this is Slow...

Way 2

After searching the Internet i found this CodePlex project, "VSTS CodeCoverage Runner - Get VS Code Coverage" from NUnit or MBUnit, located here. Which is a nice little project. The author Casey Charlton, has provided us with a great starting block (well more than that), at present the values are hard coded if you want to use the Command prompt (there is also a build task project), but you can "tweak" them so the cmd utility can be used within Studio (I will write a post about that soon).

The macanics of this project follow the basic flow

  • Add instrumentation to the Unit Testing DLL
  • Kick off the Code Coverage monitor
  • Run the unit tests, (I used MbUnit, but you can use any command line based Testing Framework)
  • Stop the monitor
  • Output the File, as a test.coverage file

thats a very quick over view of the process. However with the ".coverage" file, you can open this using the "Code Coverage Results" window and there you go!!

Here it is in action! (I now i can carry one and get some tests done!)

I was able to add coverage on the Test.dll's and all my domain ones too....

Got Ya's

After building the project you will have to add the following to you build folder 

these can be found here

c:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Performance Tools\

If these are not in the same Dir as the exe, or vise versa, the on the creation of the monitor object you will receive an error.

Further Reading

For some really interesting further reading on this topic i would suggest


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: Test
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Related posts