none
VS 2017 unable to see code coverage results with xunit RRS feed

  • Question

  • Hi , 

    I am using VS 2017 on ASP.NET core web api project using xunit to write unit tests. I checked each folder of the assembly and they all have pdb files. However  when I hit Test>Analyze Code Coverage > All or Selected Tests , then I get the output window of the Test which shows them being discovered and run. They all pass and are shown in the Test explorer .But I don't see the code coverage window. On another project running on nunit which is not ASP.NET Core , It is a WPF App. I am able to view the results in the separate window. 

    

    

    Thursday, March 9, 2017 9:50 PM

All replies

  • Hi friend,

    I got the exactly same issue as yours before.

    Code Coverage is not yet supported on .NET Core projects. This is presently a limitation.

    I've already submitted a report here:

    https://developercommunity.visualstudio.com/content/problem/21341/not-able-to-get-code-coverage-result-of-netcoreapp.html?childToView=22471#comment-22471

    And Visual Studio developing team has responded it at with a comment.

    So far it seems not be fixed yet.

    A workaround is to use a tool called Opencover, so you refer this blog to make it.

    Hope it helps. 

    Best regards,

    Fletch

     


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Fletch Zhou Sunday, March 12, 2017 3:33 AM
    • Proposed as answer by Fletch Zhou Tuesday, March 14, 2017 8:45 AM
    Sunday, March 12, 2017 3:28 AM
  • Use OpenCover + ReportGenerator (install them as NUGET packages).

    It is not very easy to configure so I have created the powershell script that you can put to your  solution folder.

    https://github.com/rpokrovskij/opencover4vs.ps1

    The main configuration parameter is a globed path to your xUnit and NUnit projects.

    $TestProjectsGlobbing = @(,'*.Test.csproj')

    The idea of the script : parse project files, collect all information, call OpenCover and ReportGenerator and open report in the browser at the end. 



    Sunday, April 9, 2017 3:41 PM