.net core projects code coverage visual studio 2017

前端 未结 6 1964
一整个雨季
一整个雨季 2021-02-01 05:15

I am using Visual Studio Enterprise 2017 to develop my .net core projects.

My solution also has some unit test projects and I want to view my current Code coverage.

6条回答
  •  广开言路
    2021-02-01 06:06

    Even with the "fixed" version I had issues (Only able to see code coverage for the test projects, not the actual projects I was testing). To workaround the problem I removed the Full from the test project.

    So, as a summary:

    1. Add package Microsoft.CodeCoverage (1.0.3) into your test project.

    2. Add the Full tag on the .csproj file on the projects we want to see code coverage values (inside as explained on the vstest github link).

    3. Run unit tests.
    4. On the "Test Explorer" select passed unit tests, right click -> "Analyze Code Coverage for Selected Tests".
    5. You should see code coverage for your assemblies.

    My setup (Minimal setup?)

    • xunit (2.3.1)
    • xunit.runner.visualstudio (2.3.1)
    • Microsoft.NET.Test.Sdk (15.3.0)
    • Microsoft.CodeCoverage (1.0.3)
    • Visual Studio Enterprise 2017 (15.4.1)

提交回复
热议问题