I want to measure the Code Coverage of my XUnit-Tests in an ASP.NET Core application. The Tooling for .NET Core in Visual Studio 2015 is preview 2 and code coverage does not work so far.
The blog post http://dotnetthoughts.net/measuring-code-coverage-of-aspnet-core-applications-using-opencover/ from February shows a workaround by using the command line of open cover. I am looking for a more integrated way inside of Visual Studio.
Has anybody heard of a better / more integrated way of measuring Code Coverage in combination with XUnit ?
Coverlet (https://github.com/tonerdo/coverlet) is a new project that has recently emerged. It works alongside msbuild and gives a straight forward solution for coverage
The codecoverage works for me, for .Net Core using
Microsoft.CodeCoverage
as mentioned above.Check you have
Microsoft.CodeCoverage
nuget added to your test projectAlso check the project.json file on you main project, the debugType attribute should be "full" instead of "portable"
This fixed for me
I have just tried the ReSharper version 2016.3 EAP 4 (Early access preview). Besides unit test execution now dotCover returns code coverage information for my .net core test projects.
OpenCover+ReportGenerator. Install as NUGET packages to one of your test projects (once, because they just need to appear in package folder).
Then you can put this powershel https://github.com/rpokrovskij/opencover4vs.ps1 to your solution folder, and setup it with your Test projects using path globing e.g.
Then you can run it as a regular Powershel script. Result should appear in Solution Folder in \TestsResults\report\index.html
Add the NuGet package Microsoft.CodeCoverage 1.0.1 to your
project.json
.I am working on Template for
Asp.NET
and right now I am working on Unit Tests so I saw your post. You could see project/configuration here.Disclaimer: These steps were given from Measuring ASP.NET Core Coverage with OpenCover - DotNetThoughts.
Even though the poster says about this site, I thought it would still be best to have these steps here for prosperity.
NOTE: These instructions while tailored to a windows operating system, should easily work for any O/S supported by OpenCover and ReportGenerator.
+[*]NAMESPACE.*
as many times as needed for each namespace