FortuneN / FineCodeCoverage

Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too)
https://marketplace.visualstudio.com/items?itemName=FortuneNgwenya.FineCodeCoverage
Other
506 stars 38 forks source link

No Code Coverage if the "CommunityToolkit.Maui" package is referenced #413

Closed pauldavis-dwe closed 2 months ago

pauldavis-dwe commented 3 months ago

Installed product versions

Description

If a project includes the "CommunityToolkit.Maui" nuget package then no code coverage results are generated

Steps to recreate

  1. Make a class library, with a class containing a public method
  2. Make a test project with a test for that public method
  3. Run the test and see code coverage results
  4. Add the "CommunityToolkit.Maui" package to the class library
  5. Run the test and see NO code coverage results

Current behavior

No code coverage results are shown

Expected behavior

Code coverage results should be shown

Cobertura XML: Cobertura.xml.txt

tonyhallett commented 3 months ago

Please can you post the contents of the FCC Output Window Pane.

tonyhallett commented 3 months ago

Also are you using ms code coverage ?

pauldavis-dwe commented 3 months ago

Coverage tab: image

Coverage Log: image

No, I'm not using MS Code Coverage

tonyhallett commented 3 months ago

Please can you post the contents of the FCC Output Window Pane.

image
tonyhallett commented 3 months ago

I think you'll find that this is not an issue with FCC but a limitation with MAUI

pauldavis-dwe commented 3 months ago

FCC output: https://pastebin.com/0JQeeqiC But if I remove the package, my test library works. So how is it MAUI?

pauldavis-dwe commented 3 months ago

Created a repo to demonstrate: https://github.com/pauldavis-dwe/FccBugRepro.git

tonyhallett commented 3 months ago

Can you set RunMsCodeCoverage Yes and see if you get the same result

pauldavis-dwe commented 3 months ago

I thought for a moment that worked, but no. It DOES now show coverage for the UnitTests project but not for the Core project: image

tonyhallett commented 3 months ago

Does the cobertura agree with what you now see ?

pauldavis-dwe commented 3 months ago

The Cobertura.xml file now has lots more in it for the Dwellant.ResidentApp.Core.UnitTests "package" but nothing for Dwellant.ResidentApp.Core which is the assembly I am testing

tonyhallett commented 3 months ago

I have installed the Maui components and run coverage on your https://github.com/pauldavis-dwe/FccBugRepro.git With the package reference and RunMsCodeCoverage Yes code coverage is collected.

image

Although with coverlet it is not. It looks like FCC will need to update the version of Coverlet that it uses to https://github.com/coverlet-coverage/coverlet/releases/tag/v6.0.0

Can you show the FCC Output Window Pane output just for the MS Code Coverage Run.

tonyhallett commented 3 months ago

Until I update coverlet you can do the following.

  1. Download the package - https://www.nuget.org/api/v2/package/coverlet.collector/6.0.2
  2. Change the file extension to zip
  3. Extract the zip
  4. Provide this directory to FCC image

--

But can you still show the FCC Output Window Pane output just for the MS Code Coverage Run.

pauldavis-dwe commented 3 months ago

I have installed the Maui components and run coverage on your https://github.com/pauldavis-dwe/FccBugRepro.git With the package reference and RunMsCodeCoverage Yes code coverage is collected.

I just tried that and I still get no coverage. Do you perhaps have a dev version or have other non-default FCC settings?

pauldavis-dwe commented 3 months ago

But can you still show the FCC Output Window Pane output just for the MS Code Coverage Run.

Sure: https://pastebin.com/Mq3UbiEF

pauldavis-dwe commented 3 months ago

Have tried the coverlet suggestion but still no coverage

tonyhallett commented 3 months ago

Sorry forget to mention that you need to add UseDataCollector project property to your test projects.

tonyhallett commented 3 months ago

Can you show the TestProject1-fcc-mscodecoverage-generated.runsettings in the bin directory.

pauldavis-dwe commented 3 months ago

Fantastic! Including UseDataCollector means I get my coverage: image

Here's TestProject1-fcc-mscodecoverage-generated.runsettings: TestProject1-fcc-mscodecoverage-generated.runsettings.txt

tonyhallett commented 3 months ago

I recognized that when I received ms coverage I hadn't included the test project so I ran again. Bizarrely, I cannot get any coverage today with any configuration.

Anyway, at least you can proceed with Coverlet.