Search code examples
c#.nettestingtest-framework

Measure C# .net code coverage via API tests


I have the pleasure to work in a project with zero unit test coverage and non testable code. The only tests that are currently existing are API tests tuning a REST/SOAP interface. Now I'm asking my self if there are possibilities to measure code/branch/line coverage by calling code via API. In the end I have to generate a report about the coverage in percent for each file which is involved in the project.


Solution

  • Not sure if Visual Studio supports it, but get yourself a copy of dotcover. It can instrument any .Net process, and gives you nice reports.

    Check the section about non-executing applications: http://blog.jetbrains.com/dotnet/2011/04/20/using-dotcover-to-cover-applications-with-or-without-resharper/