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.
When I clicked Test -> Analyze Code Coverage -> All tests. All my unit tests ran but in Code Coverage Results it only reported code coverage for my unit test projects which doesn't make any sense to me.
Question 1: Do you guys experience the same issue with me? Any solution for this? I also need to set up build definition in VSTS to report code coverage.
Question 2: Also when I right clicked to debug 1 of my unit test. It executes ALL of my unit tests. Is this a bug in VS2017?
Update1: I found this topic: https://github.com/Microsoft/vstest/issues/597
JDC's answer helped me to include my actual projects but I could not get rid of the test projects in the coverage report. I managed it by adding a "CodeCoverage.runsettings" in my XUnit test project with the following content:
The important part here is to exclude the test project in the ModulePaths section.
It looks like they are still working out the infrastructure (data collectors) bits before releasing. They are supposedly close.
https://github.com/Microsoft/vstest/issues/579
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
<DebugType>Full</DebugType>
from the test project.So, as a summary:
Add package Microsoft.CodeCoverage (1.0.3) into your test project.
Add the
<DebugType>Full</DebugType>
tag on the .csproj file on the projects we want to see code coverage values (inside<PropertyGroup>
as explained on the vstest github link).My setup (Minimal setup?)
You can try dotCover from Jetbrains. https://www.jetbrains.com/dotcover/features/
It works fine with .NET Core & can show code coverage.
This issue has been fixed with Version 15.3:
https://github.com/Microsoft/vstest-docs/blob/master/docs/analyze.md#coverage
Based on this article (Code Coverage does not work in the IDE with netcoreapp1.x projects (VS 2017 RTM):